1.确定项目技术栈
如vue2.0 + vue-cli3/4 + vue-router + axios + vuex + vant + rem + sass + webpack
2.搭建项目
以下两种方式看情况选择
1从零搭建项目
使用vue ui可视化搭建项目或指令创建项目都可
2基于原项目模板搭建项目
3.定义路由
譬如登录、首页、个人中心、搜索等需要做什么页面就定义什么页面的路由
src/router/index.js
// 定义路由
const routes = [
{ path: '/foo', component: Foo },
{ path: '/bar', component: Bar }
]
// ------------------------------------------
// 路由嵌套
{
path: '/user/:id',
component: User,
children: [
// 子路由
{
path: 'profile',
component: UserProfile
},
{
path: 'posts',
component: UserPosts
}
]
}