您好,我在从Webpack加载的pwa模板中的config / prod.env.js中的环境变量中设置基本url时遇到问题。 我将API_URL设置为“ http://localhost:3000”,并在其中运行Express JS Rest API。
错误源自的源代码行
return axios.create({
headers: {
'Content-Type': 'application/json'
},
baseURL: process.env.API_URL
})
浏览器的webpack输出
return __WEBPACK_IMPORTED_MODULE_2_axios___default.a.create({
headers: {
'Content-Type': 'application/json'
},
baseURL: http://localhost:3000/
});
浏览器控制台错误
152:40 Uncaught SyntaxError: Unexpected token :
at Object.<anonymous> (app.js:1682)
at __webpack_require__ (app.js:679)
at fn (app.js:89)
at eval (main.js?1c90:1)
at Object.<anonymous> (app.js:1207)
at __webpack_require__ (app.js:679)
at fn (app.js:89)
at Object.<anonymous> (app.js:1199)
at __webpack_require__ (app.js:679)
at app.js:725
package.json依赖项
"dependencies": {
"axios": "^0.18.0",
"vue": "^2.5.2",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
},