我的原因是在 ref组件中使用 v-for 和 v-show 这些DOM节点在mounted无法被访问到
解决方法: 把this.$refs.textinput 换成 this.$nextTick(() => { this.$refs["textinput"]; })
mounted(){
this.$nextTick(() => {
this.$refs[textinput];
})
}
如果使用了v-for 渲染出来的 这样写 this.$nextTick(() => { this.$refs["textinput"][0]; })
mounted(){
this.$nextTick(() => {
this.$refs.textinput[0];
})
}
重启项目就好了