您的位置:首页 > 产品设计 > UI/UE

vue动态组件和slot插槽

2017-08-17 11:50 691 查看
<template>
<div class="parent">
<ul>
<li @click="setNav(1)">导航一</li>
<li @click="setNav(2)">导航二</li>
<li @click="setNav(3)">导航三</li>
</ul>
<component v-bind:is="test"></component>
<slotApp>
<h1 slot="header">这是一个页面的标题</h1>
<p>这是段落</p>
<p>这是另外一个</p>
<p slot="footer">这是一些联系信息</p>
</slotApp>
</div>
</template>
<script>
import child from '../components/child/child.vue';
import childB from '../components/childB/childB.vue';
import childC from '../components/childC/childC.vue';
import slotApp from '../components/slot/slot.vue';
export default {
data(){
return {
test:'child',
}
},
methods:{
setNav(nav){
switch (nav){
case  1:
this.test = 'child';
break;
case 2:
this.test = 'childB';
break;
case 3:
this.test = 'childC';
break;
default:
this.test='child';
}
}
},
components:{
child,childB,childC,slotApp
}
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
font-weight: normal;
}

ul {
list-style-type: none;
padding: 0;
}

li {
display: inline-block;
margin: 0 10px;
}

a {
color: #42b983;
}
</style>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: