UNPKG

tt-mp

Version:

一套组件化、可复用、易扩展的头条小程序 UI 组件库

58 lines (55 loc) 937 B
import barcode from './barcode' const defalutOptions = { number: true, prefix: true, color: 'black', debug: false, onValid() {}, onInvalid() {}, onSuccess() {}, onError() {}, } Component({ properties: { width: { type: Number, value: 200, }, height: { type: Number, value: 100, }, number: { type: String, value: '', observer(newVal) { this.draw({ number: newVal, }) }, }, options: { type: Object, value: defalutOptions, }, canvasId: { type: String, value: 'wux-barcode', }, }, methods: { draw(opts = {}) { const { canvasId, number, width, height, options } = Object.assign( {}, this.data, opts ) new barcode( canvasId, number, Object.assign({ width, height }, options), this ) }, }, })