Vue router link

 

  html:

1 <router-link to="test">Go to Foo</router-link>
2 <router-link to="test1">Go to Foo1</router-link>
3 <router-view></router-view>//切换的视图容器

 

  js:

 1 var app = new Vue({
 2         el: "#app",
 3         data: {},
 4         router:new VueRouter({
 5             routes:[{
 6                 path:"/test",
 7                 component:{
 8                     template:"<p>111111111</p>"
 9                 }
10             },
11                 {
12                     path:"/test1",
13                     component:{
14                         template:"<p>22222222</p>"
15                     }
16                 }]
17         }),
18     })

 

posted @ 2019-10-09 09:55  小旺同学  阅读(298)  评论(0编辑  收藏  举报