错误:Cannot read property ' editIndex' of undefined

版权声明:共同学习,共同进步,转载请附上原文链接 https://blog.csdn.net/wy6250000/article/details/84989249

报undefined错误时,最基本的就是没有定义。而这里要提到的原因是关于this的

原因:在回调函数中用的this去取值,this的指向乱掉,找不到该字段值,陷入“回调地狱”

解决方法:在回调中用箭头函数,或者在函数块开头用let self = this,用self去取字段值

猜你喜欢

转载自blog.csdn.net/wy6250000/article/details/84989249