1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- Component({
- /**
- * 组件的初始数据
- */
- data: {
- focusIndex: 0, // 光标所在位置
- value: '', // 实际输入的值
- focus: true, // 是否获得焦点
- password: '', //替换显示的值*
- },
- /**
- * 组件的方法列表
- */
- methods: {
- setValue(e) {
- console.log(e);
- // 设置光标
- var value = e.detail.value
- this.setData({
- value: value,
- focusIndex: value.length,
- focus: value.length < 4,
- password: '*'.repeat(value.length)
- })
- },
- inputBlur(e) {
- if (e.detail.value.length === 4) {
- this.triggerEvent('complated', {
- value: e.detail.value
- })
- console.log(this.data.value);
- console.log('哈哈哈');
- this.setData({
- value: ''
- })
- let e = {
- detail: {
- value: ''
- }
- }
- this.setValue(e)
- console.log('呵呵呵');
- console.log(this.data.value);
- }
- }
- }
- })
|