Home > Web Front-end > JS Tutorial > body text

Vue.js route naming and named views

php中世界最好的语言
Release: 2018-03-13 14:43:00
Original
1908 people have browsed it

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',
    }
   ......
  ]
})
Copy after login

When used in other places outside:

<router-link :to="{name: &#39;applePage&#39;}" >to apple</router-link>
Copy after login

Named view
is similar to the named route above, add the specified name to the component

let router = new VRouter({  mode: &#39;history&#39;,  routes: [
    {      path: &#39;/apple&#39;,      //命名视图
      component: {        viewA: Apple,        viewB: RedApple
      },      //命名路由
      name: &#39;applePage&#39;,
    }
   ......
  ]
})
Copy after login

When used in other places outside:

<router-view name="viewA"></router-view>或者<router-view name="viewB"></router-view>分别插入不同的视图
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template