Cordova packages the vue project, but can't get the data with axios?

request in the vue page:

mounted () {
    axios.get("http://v.juhe.cn/toutiao/index", {
      params: {
        key: "ed0b5a46f81b282bd2ce8df1f02225d9"
      }
    })
    .then(function (res) {
      console.log(res);
      this.list = res.result.data
    })
    .catch(function (error) {
      console.log(error);
    });
}

there will be cross-domain errors when using cordova serve android, but there should be no cross-domain errors when packaged into APP?

the cordova-plugin-whitelist plug-in is installed, but it doesn"t work.

debug with chrome://inspect/-sharpdevices, the console reports an error:

ReferenceError
message: "Promise is not defined"
stack: "ReferenceError: Promise is not defined    at s.request (file:///android_asset/www/static/js/vendor.f7286bba7679aa481f9d.js:19:3108)    at s.(anonymous function) [as get] (file:///android_asset/www/static/js/vendor.f7286bba7679aa481f9d.js:19:3440)    at Function.<anonymous> (file:///android_asset/www/static/js/vendor.f7286bba7679aa481f9d.js:12:96652)    at r.mounted (file:///android_asset/www/static/js/app.d61f66b4d72913b3436e.js:1:9770)    at Vt (file:///android_asset/www/static/js/vendor.f7286bba7679aa481f9d.js:12:11193)    at nn (file:///android_asset/www/static/js/vendor.f7286bba7679aa481f9d.js:12:24778)    at Object.De.insert (file:///android_asset/www/static/js/vendor.f7286bba7679aa481f9d.js:12:20009)    at k (file:///android_asset/www/static/js/vendor.f7286bba7679aa481f9d.js:12:59576)    at kn.Ko.nodeOps [as __patch__] (file:///android_asset/www/static/js/vendor.f7286bba7679aa481f9d.js:12:60936)    at kn.t._update (file:///android_asset/www/static/js/vendor.f7286bba7679aa481f9d.js:12:33844)"
get stack: function () { [native code] }
set stack: function () { [native code] }
__proto__: Error

I really can"t find out the reason. Please give me some advice.

Jun.28,2022

"Promise is not defined", introduce Promise's polyfill


find a solution

Menu