1.5.1 • Published 1 year ago

@wines/barcode v1.5.1

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

@wines/barcode

Barcode 条形码

用于展现条形码。

使用指南

在 page.json 中引入组件

{
  "navigationBarTitleText": "Barcode",
  "usingComponents": {
    "wux-barcode": "@wines/barcode",
    "wux-cell-group": "@wines/cell-group",
    "wux-cell": "@wines/cell",
    "wux-input": "@wines/input"
  }
}

示例

<view class="page">
	<view class="page__hd">
		<view class="page__title">Barcode</view>
		<view class="page__desc">条形码</view>
	</view>
	<view class="page__bd">
		<view class="sub-title">请输入13位条形码,即时输入即时生成</view>
		<wux-cell-group>
			<wux-cell hover-class="none">
				<wux-input value="{{ number }}" controlled bind:change="onChange" />
			</wux-cell>
		</wux-cell-group>
		<view class="sub-title">提示:扫描只能识别有效的条形码</view>
		<view class="barcode">
			<wux-barcode
			 number="{{ number }}"
			 options="{{ options }}"
			 width="200"
			 height="100"
			/>
		</view>
	</view>
</view>
import './index.less';

Page({
  data: {
    number: '9787115335524',
    options: {
      // number: true,
      // prefix: true,
      // color: 'black',
      // debug: false,
      onValid() {
        console.log('onValid');
      },
      onInvalid() {
        console.log('onInvalid');
      },
      onSuccess() {
        console.log('onSuccess');
      },
      onError() {
        console.log('onError');
      },
    },
  },
  onChange(e) {
    this.setData({
      number: e.detail.value,
    });
  },
});

API

参数类型描述默认值
canvasIdstringcanvas 组件的唯一标识符wux-barcode
numberstring条形码的数值-
widthnumbercanvas 组件的宽度200
heightnumbercanvas 组件的高度100
optionsobject配置项-
options.numbertrue是否显示数字true
options.prefixtrue是否显示国家前缀true
options.colorstring条形码的颜色black
options.debugtrue是否开启调试false
options.onValidfunction验证条形码合法的回调函数-
options.onInvalidfunction验证条形码不合法的回调函数-
options.onSuccessfunction接口调用成功的回调函数-
options.onErrorfunction接口调用失败的回调函数-
1.5.1

1 year ago

1.5.0

1 year ago

1.3.5

2 years ago

1.4.0

2 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago