当前位置: 首页 > 后端技术 > Node.js

Vue-router2.0版本使用步骤

时间:2023-04-03 13:47:17 Node.js

1、定义组件(2.0版本使用router-link作为路由标签,渲染为)importVueRouterfrom'vue-router';Vue.use(VueRouter);----------------------------------------------------2.定义路由constroutes=[{path:'/goods',component:goods},{path:'/ratings',component:ratings},{path:'/seller',component:seller}];3.创建路由实例constrouter=newVueRouter({linkActiveClass:'active',routes//(缩写)等同于routes:routes});4.创建根实例,渲染,挂载newVue({router,render:h=>h(App)}).$mount('#myapp');