在构建vue-service之后丢失静态路径

时间:2019-12-25 10:28:42

标签: vue.js vue-cli

我正在将纯 HTML 网站迁移到 vue-cli 项目,但是在启动build并将其上传到服务器时{{1 }})它总是会严重转换静态路由。如果我在每条路线的前面加上``./'',则可以很好地识别它们,但是随着项目中包含更多图像,确保手动修改所有这些路线成为一个问题

是因为项目的结构还是在访问这些文件的路径中?

当前如何定义静态路由的示例

vue-cli-service build

Vue项目的<img src="../assets/imagen.jpg" />

package.json

文件夹结构:

{
  "name": "website",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.6.0",
    "vue": "^2.6.11"
  },
  "devDependencies": {
    "@vue/cli-plugin-eslint": "^4.1.1",
    "@vue/cli-plugin-babel": "^4.1.1",
    "@vue/cli-service": "^4.1.1",
    "babel-eslint": "^10.0.1",
    "eslint": "^5.16.0",
    "eslint-plugin-vue": "^6.0.1",
    "node-sass": "^4.13.0",
    "sass-loader": "^8.0.0",
    "vue-template-compiler": "^2.6.11"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "rules": {},
    "parserOptions": {
      "parser": "babel-eslint"
    }
  },
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions"
  ]
}

谢谢!

0 个答案:

没有答案