这个console.log(process)会报错,process.env.VUE_APP_BASE_API中没有读出’/api’,
如果将process.env.VUE_APP_BASE_API换成’/api’就能正常运行。是目前版本不支持process了嘛?
import axios from 'axios'
console.log(process)
const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API,
timeout: 8000
})
export default service
packgage.json内容如下
{
"name": "front-center",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^1.4.0",
"core-js": "^3.8.3",
"element-plus": "^2.3.5",
"md5": "^2.3.0",
"qs": "^6.11.2",
"vue": "^3.2.13",
"vue-router": "^4.0.11",
"vuex": "^4.0.2"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"node-sass": "^9.0.0",
"sass-loader": "^13.3.1",
"svg-sprite-loader": "^6.0.9"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
}
基于Vue3重写Vue-element-admin,打造后台前端综合解决方案
了解课程