Home  >  Article  >  Web Front-end  >  Vue.js route naming and named views

Vue.js route naming and named views

php中世界最好的语言
php中世界最好的语言Original
2018-03-13 14:43:001843browse

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: &#39;applePage&#39;}" >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: &#39;history&#39;,  routes: [
    {      path: &#39;/apple&#39;,      //命名视图
      component: {        viewA: Apple,        viewB: RedApple
      },      //命名路由
      name: &#39;applePage&#39;,
    }
   ......
  ]
})

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!

Statement:
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