mounted if thissource === WeiXIN this$nextTick = this$refsweixinclick; ; 这是vue3的逻辑吗?
这是Vue2的逻辑。在Vue3中,mounted的写法有一些变化。在Vue3中,可以使用onMounted来替代mounted钩子函数。以下是Vue3中使用onMounted的示例:
import { onMounted } from 'vue';
setup() {
onMounted(() => {
if (this.source === 'WeiXIN') {
this.$nextTick(() => {
this.$refs.weixin.click();
});
}
});
}
在Vue3中,使用setup函数来替代Vue2中的mounted钩子函数。在setup函数中,可以使用onMounted来执行需要在组件挂载后执行的逻辑。
原文地址: https://www.cveoy.top/t/topic/jgFv 著作权归作者所有。请勿转载和采集!