JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

this.$refs.ref 不存在 undefined v-if和v-show 的区别

发布时间 2023-05-23 10:26:00作者: jiduoduo

<div v-if='true'>

    <div>.... <el-input ref='ref' /> </div>

</div>

 

上面的代码,引用this.$refs.ref = undefined;

 

改为v-show解决。

 

网上有好多说法是:this.$nextTick(() => { 放这里 });在这里不能解决的。

原因: v-if条件不满足,document中是不存在的,v-show是隐藏了,还是会创建。

 

 

参考:https://huaweicloud.csdn.net/638f0ffadacf622b8df8e3a9.html

    本栏目推荐文章
  • C# 方法中的 引用参数 ref out 的使用
  • 2024-01-13 Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. ==》引用了未使用的方法导致
  • [Vue warn]: Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".
  • vue报错:Module parse failed: Unexpected token (5:2) You may need an appropriate loader to handle this file type.
  • About this page
  • JavaScript this 绑定详解
  • JavaScript this 绑定详解
  • react 事件函数中 this 绑定问题
  • mysql--You must reset your password using ALTER USER statement before executing this statement
  • keil 工程编译报错browse infomation of one or more files is not available: ……Doing a project rebuild might fix this.
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们