页面没有更新
this 的引用错了
mounted() { var _this = this ... _this.res = res.data[0].title }
最好加个this.$nextTick
this.$nextTick
楼上说了this引用错了(可以在ajax外先var _this = this;在ajax回调里面使用_this, 或者es6)
this
ajax
var _this = this;
_this
此时,楼上所说的 var _this = this;是一种方法,还有就是 把接口回调函数 改成 箭头函数()=>{}
()=>{}
this.res = ...
then方法里用箭头函数
this不能这么用。
13 回答12.9k 阅读
7 回答2.1k 阅读
9 回答1.7k 阅读✓ 已解决
6 回答1.5k 阅读
3 回答1.3k 阅读✓ 已解决
3 回答1.4k 阅读✓ 已解决
2 回答1.3k 阅读✓ 已解决
3 回答4.9k 阅读✓ 已解决
3 回答9.7k 阅读
4 回答9k 阅读✓ 已解决
1 回答2k 阅读
2 回答497 阅读✓ 已解决
this 的引用错了