The vcode @wines
@wines/vcode用于展现验证码。
``json`
{
"navigationBarTitleText": "wux-vcode",
"usingComponents": {
"wux-vcode": "@wines/vcode"
}
}
`xml
str="1234567890"
bgColor="#e6f6ff"
fontColor="#165189"
hasPoint
hasLine
bind:change="onChange"
/>
`
`ts
import './index.less';
import { $wuxVcode } from '@wines/vcode';
Page({
data: {},
onLoad() {
/* /
},
onChange(e) {
console.log(验证码:${e.detail.value as string});`
},
onClick() {
const vcode = $wuxVcode('#wux-vcode');
if (vcode) {
vcode.draw();
}
},
});
| 参数 | 类型 | 描述 | 默认值 |
| ----------- | ---------- | ------------------ | -------------------------------------------------------------- |
| str | string | 验证码范围 | ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 |number
| num | | 验证码长度 | 6 |number
| width | | 画布宽度 | 120 |number
| height | | 画布高度 | 40 |string
| bgColor | | 画布背景色 | - |string
| fontColor | | 画布字体颜色 | - |boolean
| hasPoint | | 是否显示干扰点 | true |boolean
| hasLine | | 是否显示干扰线 | true |function` | 点击事件的回调函数 | - |
| bind:change |