<div id="app">
<children>
<span>12345</span>
<!--上面这行不会显示-->
</children>
</div>
<script>
var vm = new Vue({
el: '#app',
components: {
children: { //这个无返回值,不会继续派发
template: "<button>为了明确作用范围,所以使用button标签</button>"
}
}
});
</script>
<div id="app">
<children>
<span>12345</span>
<!--上面这行不会显示-->
</children>
</div>
<script>
var vm = new Vue({
el: '#app',
components: {
children: { //这个无返回值,不会继续派发
template: "<button><slot></slot>为了明确作用范围,所以使用button标签</button>"
}
}
});
</script>
<div id="app">
<children>
<span slot="first">12345</span>
<span slot="second">56789</span>
<!--上面这行不会显示-->
</children>
</div>
<script>
var vm = new Vue({
el: '#app',
components: {
children: { //这个无返回值,不会继续派发
template: "<button><slot name='first'></slot>为了明确作用范围,<slot name='second'></slot>所以使用button标签</button>"
}
}
});
</script>
<button> <span slot="first">12345</span> 为了明确作用范围, <span slot="second">56789</span> 所以使用button标签 </button>
<div id="app">
<children>
<span slot="first" @click="tobeknow">12345</span>
<span slot="second">56789</span>
<!--上面这行不会显示-->
</children>
</div>
<script>
var vm = new Vue({
el: '#app',
methods: {
tobeknow: function () {
console.log("It is the parent's method");
}
},
components: {
children: { //这个无返回值,不会继续派发
template: "<button><slot name='first'></slot>为了明确作用范围,<slot name='second'></slot>所以使用button标签</button>"
}
}
});
</script>
<div id="app">
<children>
<span slot="first">【12345】</span>
<!--上面这行不会显示-->
</children>
</div>
<script>
var vm = new Vue({
el: '#app',
components: {
children: { //这个无返回值,不会继续派发
template: "<div><slot name='first'><button>【如果没有内容则显示我1】</button></slot>为了明确作用范围,<slot name='last'><button>【如果没有内容则显示我2】</button></slot>所以使用button标签</div>"
}
}
});
</script>
<div id="app">
<button @click="toshow">点击让子组件显示</button>
<children v-if="abc">
</children>
</div>
<script>
var vm = new Vue({
el: '#app',
data: {
abc: false
},
methods: {
toshow: function () {
this.abc = !this.abc;
}
},
components: {
children: { //这个无返回值,不会继续派发
template: "<div>这里是子组件</div>"
}
}
});
</script>
<div id="app">
<button @click="toshow">点击让子组件显示</button>
<children>
<span slot="first">【12345】</span>
<!--上面这行不会显示-->
</children>
</div>
<script>
var vm = new Vue({
el: '#app',
methods: {
toshow: function () {
this.$children[0].tohidden = true;
}
},
components: {
children: { //这个无返回值,不会继续派发
template: "<div v-if='tohidden' @click='tohide'>这里是子组件</div>",
data: function () {
return {
tohidden: true
}
},
methods: {
tohide: function () {
this.tohidden = !this.tohidden;
}
}
}
}
});
</script>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有