解决van-search自动聚焦失败
focusEvent(){
this.$nextTick(() => {
try {
const input = document.getElementsByClassName("van-field__control")[0];
input.focus();
} catch (e) {}
});
},
在mounted或activated时引入上述代码即可解决
在Vue应用中,通过在`mounted`或`activated`生命周期钩子中使用`this.$nextTick`配合`document.getElementsByClassName`获取元素并调用`focus()`方法,可以解决van-search组件自动聚焦失败的故障。
6024

被折叠的 条评论
为什么被折叠?



