axios.get('__MODULE__/Point/getPointProduct', {
params: {
productno:app.pointproduct_no
}
}).then(function (response) {
app.thisProductNewPrice=response.data[0].NewPrice;
});
app.pointproduct_no获取不到值
但是为什么以下代码加一个定时器就可以执行
setInterval(function(){
axios.get('__MODULE__/Point/getPointProduct', {
params: {
productno:app.pointproduct_no
}
}).then(function (response) {
app.thisProductNewPrice=response.data[0].NewPrice;
});
},1000);
把 axios 的代码放到 app 的 created 勾子中。如下:
从你的描述上看,app 应该是在 axios 后才被定义,或者 app 是一个异步加载的对象。你通过 setInterval 把 axios 的执行延迟了,所以 app 出来了,axios 不报错了