This time I will bring you the routingnaming and namingview of Vue.js, what are the notes of Vue.js routing naming and naming the view? , the following is a practical case, let’s take a look.
Route naming We can set a name attribute when setting the route, during the navigation process directly: to="{name: 'corresponding name'} "You can
let router = new VRouter({ mode: 'history', routes: [ { path: '/apple', component: Apple, //命名路由 name: 'applePage', } ...... ] })
When used in other places outside:
<router-link :to="{name: 'applePage'}" >to apple</router-link>
Named view
is similar to the named route above, add the specified name to the component
let router = new VRouter({ mode: 'history', routes: [ { path: '/apple', //命名视图 component: { viewA: Apple, viewB: RedApple }, //命名路由 name: 'applePage', } ...... ] })
When used in other places outside:
<router-view name="viewA"></router-view>或者<router-view name="viewB"></router-view>分别插入不同的视图
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to the php Chinese website Other related articles!
Recommended reading:
Other operations of Vue.js routing
Vue.js single component component
The above is the detailed content of Vue.js route naming and named views. For more information, please follow other related articles on the PHP Chinese website!