90 lines
2.2 KiB
Plaintext
90 lines
2.2 KiB
Plaintext
<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 text="01234567890128"></l-barcode>
|
|
</view>
|
|
</view>
|
|
<view class="demo-block card">
|
|
<text class="demo-block__title-text large">自定义文本样式</text>
|
|
<view class="demo-block__body">
|
|
<l-barcode ref="barcodeRef" text="01234567890128" lineWidth="2px" lineLength="30px" lineColor="blue" format="codabar" margin="5px"></l-barcode>
|
|
<button style="margin-top: 10px;" @click="onClick">生成图片</button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
<script lang="uts" setup>
|
|
const barcodeRef = ref<LBarcodeComponentPublicInstance|null>(null);
|
|
|
|
const onClick = () => {
|
|
if(barcodeRef.value != null){
|
|
barcodeRef.value!.canvasToTempFilePath({
|
|
success(res: UTSJSONObject){
|
|
console.log('res', res)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
</script>
|
|
<style lang="scss">
|
|
$card-bg-color: var(--doc-card-bg-color, white);
|
|
// $page-bg-color: var(--doc-page-bg-color, #f5f5f5);
|
|
$title-color: var(--doc-title-color, #000000E6);
|
|
$summary-color: var(--doc-summary-color, #00000099);
|
|
|
|
|
|
.demo-block {
|
|
margin: 32px 10px 0;
|
|
overflow: visible;
|
|
&.card{
|
|
padding: 30rpx;
|
|
background-color: $card-bg-color;
|
|
transition-property: background-color;
|
|
// transition-duration: 300ms;
|
|
margin-bottom: 20rpx !important;
|
|
}
|
|
&__title {
|
|
margin: 0;
|
|
margin-top: 8px;
|
|
&-text {
|
|
color: $summary-color;
|
|
font-weight: 400;
|
|
font-size: 14px;
|
|
line-height: 16px;
|
|
|
|
&.large {
|
|
color: $title-color;
|
|
font-size: 18px;
|
|
font-weight: 700;
|
|
line-height: 26px;
|
|
}
|
|
&.ultra {
|
|
color: $title-color;
|
|
font-size: 24px;
|
|
font-weight: 700;
|
|
line-height: 32px;
|
|
}
|
|
}
|
|
}
|
|
&__desc-text {
|
|
color: $summary-color;
|
|
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> |