vue2.0
1.安装vue-router 命令:npm install vue-router --save
index.js中进行2-5
2.引入相关组件
3.配置路径 路径一定不能错哟
4.导出
5.router and routes very important
App.vue中 \
router-view 非常重要
main.js中
一定要有两个动作:
全局注入
渲染出口
vue3.0
1.安装vue-router 命令:npm install vue-router@next --save
2-5的步骤和vue2.0一样,这里记录一下在安装vue3.0中出现的错误
question one
写好一个组件,运行后出现
is not a function 他是路由问题,所以去看了index.js
question two
index.js显示not found vue-router and no such file or dictory \
not found vue-router是这样的 \
找了半天才发现是vue-router版本的问题 去package.json 查看vue-router 是这样的就是对的
no such file or dictory \
这个就很简单了 npm run serve 重启项目即可
question three
输入index.js中的路径一直都是这个页面
那这个问题加上router-view就可以了,就是开头所讲的router-view 这个很重要,因为要用来显示视图
本文记录2020-12-2 学习vue2和vue3中vue-router出现的错误和重要知识点 有什么不足或建议欢迎来评论区