Vue之axios请求表格数据时能正确返回数据,但是总是不能渲染进页面

原本是这样写的
在这里插入图片描述
但是发现一直会报下面这个错误
在这里插入图片描述
查找一下原因,在 then的内部不能使用Vue的实例化的this, 因为在内部 this 没有被绑定
解决方法有:
(1)用ES6箭头函数,箭头方法可以和父方法共享变量
(2)在请求axios外面定义一下 var that=this
参考文档:https://blog.csdn.net/qq_42809973/article/details/83084566

猜你喜欢

转载自blog.csdn.net/weixin_40736319/article/details/89385832