首页 > 其他 > 详细

vue 实例化定义路由模板

时间:2018-02-08 11:59:53      阅读:194      评论:0      收藏:0      [点我收藏+]
 <div id="app">
    <router-view></router-view>
  </div>
  <template id="a">
    <div @click="link">hello</div>
  </template>
  <template id="b">
    <div>world</div>
  </template>
  const Home = Vue.extend({
    template: "#a",
    data: function() {
      return {}
    },
    methods: {
      link: function () {
        this.$router.push(‘/b‘)
      }
    }
  })
  const B = Vue.extend({
    template: "#b"
  })
  // 路由
  const routes = [
    {path:‘/‘,component:Home},
    {path:‘/b‘,component:B}
  ];
  const router = new VueRouter({
    routes
  })
  new Vue({
    el:"#app",
    router
  })

 

vue 实例化定义路由模板

原文:https://www.cnblogs.com/kelly07/p/8430643.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!