1、安装vue及建项目
安装及启动项目vue:npm install -g @vue/cli@3.0.4
创建vue项目:vue create hello-world
进入项目目录:cd hello-world
运行项目: npm run serve
2、修改代码:
找到src->components目录,新建vue文件,可以编辑页面元素
打开App.vue,引入新加入对vue文件及挂载
3、在首页新增页面入口:
在项目目录下cd hello-world执行命令:vue add router
找到router.js增加新入口代码
{
path: '/One',
name: 'One',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ './components/one.vue')
}
app.vue里面的代码会自动更新,再增加新入口代码
<router-link to="/One">One</router-link>
4、刷新页面新增one入口