js代码
mounted() {
let val = [];
let str = "";
let ipt = document.getElementById('ipt');
ipt.addEventListener('keyup',function () {
val.push(ipt.value);
if(val.length){
if(val.length >= str.length) {
str += val;
}else {
str = str.substr(0, val.length)
}
this.value = val.replace(/./g, '*')
}
}, false)
},
用vue为什么不用双向数据绑定呢?
还有你监听的keyup方法是否已触发?你的赋值是在这个方法触发后