105 lines
2.2 KiB
Vue
105 lines
2.2 KiB
Vue
<template>
|
|
<view class="demo-block">
|
|
<text class="demo-block__title-text ultra">条形码</text>
|
|
<text class="demo-block__desc-text">条形码</text>
|
|
<view class="demo-block__body">
|
|
<view class="demo-block card">
|
|
<text class="demo-block__title-text large">基础</text>
|
|
<view class="demo-block__body">
|
|
<!-- <l-barcode ref="barcodeRef" text="1234567890128" lineWidth="4rpx" lineLength="30px" lineColor="blue" format="ean13" margin="5px"></l-barcode> -->
|
|
<l-barcode ref="barcodeRef" text="1234567890128" lineWidth="4rpx" lineLength="30px" lineColor="blue" format="codabar" margin="5px"></l-barcode>
|
|
<button @click="onClick">生成图片</button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
<script>
|
|
import { defineComponent, ref, onMounted } from '@/uni_modules/lime-shared/vue';
|
|
|
|
export default defineComponent({
|
|
setup() {
|
|
const barcodeRef = ref(null);
|
|
|
|
const onClick = ()=>{
|
|
if(barcodeRef.value){
|
|
barcodeRef.value.canvasToTempFilePath({
|
|
success(res){
|
|
console.log('res', res)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
return {
|
|
barcodeRef,
|
|
onClick
|
|
}
|
|
}
|
|
})
|
|
|
|
</script>
|
|
<style lang="scss">
|
|
// *{overflow:visible}
|
|
.preview {
|
|
padding-top: 20px;
|
|
flex-direction: row;
|
|
justify-content: space-around;
|
|
overflow: visible;
|
|
// padding-left: 20px;
|
|
}
|
|
|
|
.child {
|
|
width: 50px;
|
|
height: 50px;
|
|
background: #eee;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.demo-block {
|
|
margin: 32px 10px 0;
|
|
overflow: visible;
|
|
&.card{
|
|
padding: 30rpx;
|
|
background-color: white;
|
|
margin-bottom: 20rpx;
|
|
}
|
|
&__title {
|
|
margin: 0;
|
|
margin-top: 8px;
|
|
&-text {
|
|
color: rgba(0, 0, 0, 0.6);
|
|
font-weight: 400;
|
|
font-size: 14px;
|
|
line-height: 16px;
|
|
|
|
&.large {
|
|
color: rgba(0, 0, 0, 0.9);
|
|
font-size: 18px;
|
|
font-weight: 700;
|
|
line-height: 26px;
|
|
}
|
|
&.ultra {
|
|
color: rgba(0, 0, 0, 0.9);
|
|
font-size: 24px;
|
|
font-weight: 700;
|
|
line-height: 32px;
|
|
}
|
|
}
|
|
}
|
|
&__desc-text {
|
|
color: rgba(0, 0, 0, 0.6);
|
|
margin: 8px 16px 0 0;
|
|
font-size: 14px;
|
|
line-height: 22px;
|
|
}
|
|
&__body {
|
|
margin: 16px 0;
|
|
overflow: visible;
|
|
.demo-block {
|
|
// margin-top: 0px;
|
|
margin: 0;
|
|
}
|
|
}
|
|
}
|
|
</style> |