本来this 是指向vue,但是在axios 中 域被改变,解决办法:用变量that 存储this,操作document就用that来指向
示例代码:
mounted: function () { /*初始化页面内容*/
axios.post('/custom/view').then(
function (res)
{
try {
var that = this;//存储
this that.setJSON(JSON.parse(res.data.formEle));
}
catch (e)
{ this.$message.error(e.message),
this.$refs.uploadJson.end()
}
});