首页 > 其他 > 详细

vue路由组件群

时间:2017-02-16 11:36:31      阅读:217      评论:0      收藏:0      [点我收藏+]

import Vue from ‘vue‘
import VueRouter from ‘vue-router‘
Vue.use(VueRouter)

const first = {
template: ‘<div>first内容</div>‘
}
const second = {
template: ‘<div>second内容</div>‘
}
const home = {
template: ‘<div>home内容</div>‘
}
const hehe = {
template: ‘<div>hehe内容</div>‘
}

const router = new VueRouter({
mode: ‘history‘,
base: __dirname,
routes: [{
path: ‘/‘,
components: {
default: home,
left: first
}
}, {
path: ‘/first‘,
components: {
default: hehe,
right: second
}
}]
})

new Vue({
router,
template: `
<div id="r">
<h1>导航</h1>
<p>{{$route.name}}</p>
<ol>
<li><router-link to="/">/</router-link></li>
<li><router-link to="/first">/first</router-link></li>
</ol>
<router-view class="sade"></router-view>
<router-view class="sade1" name="left" style="float: left; height: 200px;width: 41%; backgroundColor: #ff6600;"></router-view>
<router-view class="sade2" name="right" style="float: right; height: 200px;width: 41%; backgroundColor: #ff9900;"></router-view>
</div>
`
}).$mount(‘#app‘)

vue路由组件群

原文:http://www.cnblogs.com/wangujianchi/p/6404518.html

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