After vue is packaged and uploaded to the server, it can be accessed using the server domain name, and the page can be displayed, but no background data is requested.

background console reports an error:

    
vendor.079528d0399e130331bb.js:12 TypeError: x is not a function
at a.getData (app.6ef2ec9d0b2dc1783aed.js:1)
at a.created (app.6ef2ec9d0b2dc1783aed.js:1)
at wt (vendor.079528d0399e130331bb.js:12)
at a.e._init (vendor.079528d0399e130331bb.js:12)



ip

 

config- index.js

dev: {
env: require("./dev.env"),
host: "xx.1.xx.xx",   //
port: 8888,
autoOpenBrowser: false,
assetsSubDirectory: "static",
assetsPublicPath: "/",
proxyTable: {
  "/backxxxxxx": {    //

    target: "http://xxxx.sxxxxxx.cn/", // 

    changeOrigin: true,
    pathRewrite: {
      "^/bxxxx": "/bxxxxxx"
    }
  }
},

Sep.18,2021
The interface proxy set by

proxyTable is only valid in the development environment. For the specific interface address, you need to set the baseURL, in your interceptor to the server domain name or comment out


config-index.js. The dev configuration is related to the local request backend and uploaded to the official or test server. The domain name configuration is in the prod.env.js file


.

proxyTable is used by webpack's devServer. If you pack it, you can write
ROOT_URL:' ""'in prod.env.js; (note that there is a double colon in the single colon)
, and then write

on the js file that uses axios.

const ROOT_URL=process.env.ROOT_URL;
export const root = ROOT_URL;
you can write something like this on request:
export const userLogin = (query) = > axios.post ( ${root} / api/authenticate , query),
so that axios will request
http: / / IP:port/api/authenticate

directly after packaging.
Menu