齐鲁信息网  欢迎您! 设为首页

获取《2019超级智能城市2.

超级智能城市2.0 :2050

12月27日,腾讯微信公众号发

微信正式上线“问医生”功能:有

秋冬季节最适合穿什么,答案虽然

同样是卫衣,为什么陈坤穿帅到尖

哪个爱美的女人不涂口红?只要带

涂口红的小技巧:咬唇,渐变唇,

Vue单页面的动态组件

2020-03-26 07:34:19 来源: 阅读:-

<template id="my-A">
<div>
<p >{{title}}</p>
</div>
</template>
<template id="my-B">
<div>
<p >B组件</p>
</div>
</template>
<template id="my-C">
<div>
<p >C组件</p>
</div>
</template>
<div id="app">
<!-- 动态组件 一-->
<button @click="flag= 'a'">a组件</button>
<button @click="flag= 'b'">b组件</button>
<my-a v-if="flag=='a'" :title=" 'aaaa组件' "></my-a>
<my-a v-if="flag=='b'" :title=" 'bbbb组件' "></my-a>
<hr>
<!-- 动态组件 二 判断的是组件的名称-->
<button @click="flag2= 'my-b'">b组件</button>
<button @click="flag2= 'my-c'">c组件</button>
<component :is="flag2"></component>
</div>

<script>
new Vue({
el:'#app',
data:{
flag:'a',
flag2:'my-b'
},
components:{ //组件
'my-a':{
template:'#my-A',
props:['title']
},
'my-b':{
template:'#my-B',
},
'my-c':{
template:'#my-C',
}
}
});
</script>

推荐阅读:麒麟710和骁龙845哪个好