The problem that vue is unable to get the value

axios.get("__MODULE__/Point/getPointProduct", {
    params: {
        productno:app.pointproduct_no
    }
}).then(function (response) {

    app.thisProductNewPrice=response.data[0].NewPrice;
});
        
        
        app.pointproduct_no
        

clipboard.png

clipboard.png

but why can the following code add a timer to execute

 setInterval(function(){
                axios.get("__MODULE__/Point/getPointProduct", {
                    params: {
                        productno:app.pointproduct_no
                    }
                }).then(function (response) {

                    app.thisProductNewPrice=response.data[0].NewPrice;
                });
            },1000);
Mar.04,2021

put the axios code in the created box of app. As follows:

const app = new Vue(
    {
        data: {...},
        created() {
            // axios 
        }
    }
);

from your description, app should not be defined until after axios, or app is an asynchronously loaded object. You delayed the execution of axios through setInterval, so app came out and axios did not report wrong

.
Menu