如何在vue-cli上更改main.js的路径?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在vue-cli上更改main.js的路径?相关的知识,希望对你有一定的参考价值。
我用vue-cli
我想更改main.js和其他vue源文件的路径
所以,我试图改变build / webpack.base.conf.js
像这样。(它是build / webpack.base.conf.js的一部分
(之前)
module.exports = {
entry: {
app: './src/main.js'
},
(后)
module.exports = {
entry: {
app: '../src/main.js'
},
我试着开始
npm run dev
但它不起作用
它打印出此错误消息
These dependencies were not found:
* vue in ../src/main.js, ../src/store/index.js and 9 others
* vue-router in ../src/main.js
* vuex-router-sync in ../src/main.js
* es6-promise/auto in ../src/main.js
* vuex in ../src/store/index.js
* !!babel-loader!../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./App.vue in ../src/components/App.vue
* !!babel-loader!../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./Dash.vue in ../src/components/Dash.vue
* !!babel-loader!../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./Login.vue in ../src/components/Login.vue
* !!babel-loader!../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./404.vue in ../src/components/404.vue
* !!babel-loader!../../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./Device.vue in ../src/components/views/Device.vue
* !!babel-loader!../../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./Messagegt.vue in ../src/components/views/Messagegt.vue
* !!babel-loader!../../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./Monitor.vue in ../src/components/views/Monitor.vue
* !!babel-loader!../../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./Firewall.vue in ../src/components/views/Firewall.vue
* !!babel-loader!../../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./Performance.vue in ../src/components/views/Performance.vue
* !!vue-style-loader!css-loader?{"minimize":false,"sourceMap":false}!../../myVue/node_modules/vue-loader/lib/style-compiler/index?{"id":"data-v-44394314","scoped":false,"hasInlineConfig":false}!../../myVue/node_modules/vue-loader/lib/selector?type=styles&index=0!./Dash.vue in ../src/components/Dash.vue
* !!vue-style-loader!css-loader?{"minimize":false,"sourceMap":false}!../../myVue/node_modules/vue-loader/lib/style-compiler/index?{"id":"data-v-1db248d7","scoped":false,"hasInlineConfig":false}!../../myVue/node_modules/vue-loader/lib/selector?type=styles&index=0!./Login.vue in ../src/components/Login.vue
* !!vue-style-loader!css-loader?{"minimize":false,"sourceMap":false}!../../myVue/node_modules/vue-loader/lib/style-compiler/index?{"id":"data-v-808c2e74","scoped":false,"hasInlineConfig":false}!../../myVue/node_modules/vue-loader/lib/selector?type=styles&index=0!./404.vue in ../src/components/404.vue
* vue-hot-reload-api in ../src/components/App.vue, ../src/components/Dash.vue and 16 others
To install them, you can run: npm install --save vue vue-router vuex-router-sync es6-promise/auto vuex !!babel-loader!../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./App.vue !!babel-loader!../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./Dash.vue !!babel-loader!../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./Login.vue !!babel-loader!../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./404.vue !!babel-loader!../../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./Device.vue !!babel-loader!../../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./Messagegt.vue !!babel-loader!../../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./Monitor.vue !!babel-loader!../../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./Firewall.vue !!babel-loader!../../../myVue/node_modules/vue-loader/lib/selector?type=script&index=0!./Performance.vue !!vue-style-loader!css-loader?{"minimize":false,"sourceMap":false}!../../myVue/node_modules/vue-loader/lib/style-compiler/index?{"id":"data-v-44394314","scoped":false,"hasInlineConfig":false}!../../myVue/node_modules/vue-loader/lib/selector?type=styles&index=0!./Dash.vue !!vue-style-loader!css-loader?{"minimize":false,"sourceMap":false}!../../myVue/node_modules/vue-loader/lib/style-compiler/index?{"id":"data-v-1db248d7","scoped":false,"hasInlineConfig":false}!../../myVue/node_modules/vue-loader/lib/selector?type=styles&index=0!./Login.vue !!vue-style-loader!css-loader?{"minimize":false,"sourceMap":false}!../../myVue/node_modules/vue-loader/lib/style-compiler/index?{"id":"data-v-808c2e74","scoped":false,"hasInlineConfig":false}!../../myVue/node_modules/vue-loader/lib/selector?type=styles&index=0!./404.vue vue-hot-reload-api
> Listening at http://localhost:8080
如何更改vue源路径?
请帮我
答案
在那条路上有main.js
吗?
../src/main.js
是以下目录结构是相同的:
- 根目录 SRC main.js 目录 的package.json 其他文件..
如果vue
文件位于以下路径中。
- root direcotry SRC main.js 目录 SRC App.vue 的package.json 其他文件..
你必须从main.js加载为import App from '../directory/src/App.vue'
但如果vue
文件位于以下路径中。
- 根目录 SRC main.js App.vue 目录 的package.json 其他文件..
你必须从main.js加载为import App from './App.vue'
是不是只是移动main.js?
检查main.js.
以上是关于如何在vue-cli上更改main.js的路径?的主要内容,如果未能解决你的问题,请参考以下文章