const service = axios.create({ baseURL: 'http://172.26.0.252:8881', timeout: 5000 })
其实呢这个值应该设置在.env中,设置VUE_APP_BASE_API
1
VUE_APP_BASE_API=http://172.26.0.252:8881
远程调用
解决了跨域之后,开始了实际的接口调用,修改的是登录页面,一测试,报这样的错。
1 2 3 4 5 6 7 8 9 10
login error:Error: ERR_ACTION_ACCESS_UNDEFINED: Are you trying to access this.someMutation() or this.someGetter inside an @Action? That works only in dynamic modules. If not dynamic use this.context.commit("mutationName", payload) and this.context.getters["getterName"] Error: Could not perform action Login at Store.eval (webpack-internal:///./node_modules/vuex-module-decorators/dist/esm/index.js:333:37) at step (webpack-internal:///./node_modules/vuex-module-decorators/dist/esm/index.js:114:23) at Object.eval [asthrow] (webpack-internal:///./node_modules/vuex-module-decorators/dist/esm/index.js:95:53) at rejected (webpack-internal:///./node_modules/vuex-module-decorators/dist/esm/index.js:86:65) Error: error with code: undefined at __webpack_exports__.default (webpack-internal:///./src/utils/request.ts:48:133)