>
</view>
</view>
</view>
</view>
</view>
<button class="userLocation">
<text class="b_content">
Verify Now
</text>
</button>
</view>
</template>
<script>
export default{
data(){
return{
num:2,
that:this,
obj:['','','','']
}
},
computed:{
ctSize() {
return this.obj.length;
},
},
methods:{
changeInput(e){
console.log(this.ctSize)
},
focus(){
console.log("获得焦点")
},
onFocus(){
let index =this.obj.findIndex(item=>{return item ==''})
index=(index+this.ctSize) % this.ctSize;
console.log(index)
console.log(this.$refs.input[index])
this.$refs.input[index].focus();
}
}
}
</script>
1***@qq.com (作者)
是这样的,我ref获取到了,但是focus调不到
2020-08-22 13:50
深海智行
回复 1***@qq.com: 哦,你用错了,不是这么用的,你看文档,设置focus属性
2020-08-22 17:31
1***@qq.com (作者)
回复 深海智行:直接设置属性就会 报这个错Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "focus"所以没用
2020-08-22 19:12
深海智行
回复 1***@qq.com: 哦,你还是用错了,这样: : focus="focus"
2020-08-24 16:56