1.和vue的生命周期有关,必须要在从mounted开始拿,才能拿得到里面的Dom元素

2.想在element ui 对话框打开后取dom时,应该使用$nextTick,而不是直接使用this.$refs. imgLocal2

        console.log('this.$refs.imgLocal2外面', this.$refs.imgLocal2);
setTimeout(() => {
console.log('this.$refs.imgLocal2 setTimeout', this.$refs.imgLocal2);
}, 500); // 不推荐
this.$nextTick(() => {
console.log('this.$refs.imgLocal2 $nextTick', this.$refs.imgLocal2);
});

vue中this.$refs可以拿到,但是里面的属性undefind的问题的更多相关文章

  1. vue中使用refs定位dom出现undefined?

    之前在公司做项目,一直感觉用ref来定位dom节点挺方便的.但是期间遇到了一个问题,就是在mounted(){}钩子里面使用this.$refs.xxx,打印出来的却是undefined? 于是我就对 ...

  2. typescript无法识别vue中的$refs

    例如:vue-fullscreen <template> <div class="Test"> <fullscreen ref="fulls ...

  3. 针对vue中请求数据对象新添加的属性不能响应式的解决方法

    1.需要给对象添加属性时,不能采用传统的obj.属性=值,obj[属性]=值 来添加属性,在vue页面时需要这样使用 this.$set(obj,"propertyName",&q ...

  4. vue中watch检测到不到对象属性的变化的解决方法

    watch: { option: { handler(newVal) { console.log(newVal); }, deep: true, immediate: true } }, 需要深层wa ...

  5. 在vue中操作dom元素

    在vue中可以通过给标签加ref属性,就可以在js中利用ref去引用它,从而达到操作该dom元素,以下是个参考例子 1 <template> 2 <div> 3 <div ...

  6. vue中什么样的数据可以是在视图中显示

    1. Vue中不可以添加不存在的属性,因为不存在的属性是没有getter和setter的. <div id="app"> {{msg.a}} {{msg.b}} < ...

  7. vue中如何实现数据的双向绑定

    vue中如何实现数据的双向绑定 实现视图变化数据跟着变:分两步,上面get中的为第二步(即再次读取的时候会调用get方法得到之前设置的值,以此来实现动态改变) 由于直接写obj.name = this ...

  8. vue系列---理解Vue中的computed,watch,methods的区别及源码实现(六)

    _ 阅读目录 一. 理解Vue中的computed用法 二:computed 和 methods的区别? 三:Vue中的watch的用法 四:computed的基本原理及源码实现 回到顶部 一. 理解 ...

  9. 详解Vue中的computed和watch

    作者:小土豆 博客园:https://www.cnblogs.com/HouJiao/ 掘金:https://juejin.cn/user/2436173500265335 1. 前言 作为一名Vue ...

随机推荐

  1. 写第一个 swift,iOS 8.0程序

    class ViewController: UIViewController { @IBAction func btn_click(sender : AnyObject) { println(&quo ...

  2. Windows Nginx 教程

    1. 下载Nginx: Nginx下载 (官方网站) 作者使用版本  Stable version  nginx/Windows-1.12.0

  3. 小部分安卓手机 reload 等方法不执行

    自己解析 url 来赋值刷新页面  方法如下:// location.href function updateUrl(url, key) {     var key = (key || 't') + ...

  4. js数组去重练习

  5. 解决码云未配置公钥问题——fatal: Could not read from remote repository.

    使用码云,键入“git push -u origin master” ,遇到如下问题: fatal: Could not read from remote repository.(致命:不能读远端仓库 ...

  6. teb教程4

    障碍物避障以及机器人足迹模型 简介:障碍物避障的实现,以及必要参数的设置对于机器人足迹模型和其对应的影响 1.障碍物避障是怎样工作的 1.1 惩罚项 障碍物避障作为整个路径优化的一部分.显然,优化是找 ...

  7. Nodejs base64编码与解码

    1、普通字符串 //编码 new Buffer(String).toString('base64'); //解码 new Buffer(base64Str, 'base64').toString(); ...

  8. ubuntu安装及破解WebStorm11

    ubuntu安装及破解WebStorm11 下载地址:http://www.jetbrains.com/webstorm/download/#section=linux-version 1.qingy ...

  9. mybatis xml中大于号小于号的代替

    第一种写法(1): 原符号 < <= > >= & ' "替换符号 < <= > >= & &apos; " ...

  10. 【leetcode】977. Squares of a Sorted Array

    题目如下: Given an array of integers A sorted in non-decreasing order, return an array of the squares of ...