第一种情况:内部有两个独立插槽(模板自动迭代2次)

<!DOCTYPE html>
<html> <head>
<title> hello world vue </title>
<meta charset="utf-8" />
</head> <body>
<div id="app" v-cloak>
<child-component>
<template scope="props">
<p>来自父组件的内</p>
<p> {{props.msg1}}</p>
<p> {{props.msg2}}</p>
<p> {{props}}</p>
<hr>
</template>
</child-component>
</div>
</body> </html> <script src="jquery-3.1.1.js"></script>
<script src="vue.js"></script> <script>
$(document).ready(function() { });
</script> <script>
var bus = new Vue(); Vue.component('child-component', {
template: '\
<div class="container">\
<slot msg1="来自子组件的内容1"></slot>\
<slot msg2="来自子组件的内容2"></slot>\
<div>',
props: [],
data: function() {
return {}
},
methods: {}
}); var app = new Vue({
el: '#app',
data: {
showChild: true
},
computed: {},
methods: {},
components: {},
mounted: function() {}
});
</script>
来自父组件的内

来自子组件的内容1

{ "msg1": "来自子组件的内容1" }

---------------------------------------
来自父组件的内 来自子组件的内容2 { "msg2": "来自子组件的内容2" }

第二种情况:内部有1个独立插槽(虽然有两个变量,模板仅仅迭代一次)

<!DOCTYPE html>
<html> <head>
<title> hello world vue </title>
<meta charset="utf-8" />
</head> <body>
<div id="app" v-cloak>
<child-component>
<template scope="props">
<p>来自父组件的内</p>
<p> {{props.msg1}}</p>
<p> {{props.msg2}}</p>
<p> {{props}}</p>
<hr>
</template>
</child-component>
</div>
</body> </html> <script src="jquery-3.1.1.js"></script>
<script src="vue.js"></script> <script>
$(document).ready(function() { });
</script> <script>
var bus = new Vue(); Vue.component('child-component', {
template: '\
<div class="container">\
<slot msg1="来自子组件的内容1" msg2="来自子组件的内容2"></slot>\
<div>',
props: [],
data: function() {
return {}
},
methods: {}
}); var app = new Vue({
el: '#app',
data: {
showChild: true
},
computed: {},
methods: {},
components: {},
mounted: function() {}
});
</script>
来自父组件的内

来自子组件的内容1

来自子组件的内容2

{ "msg1": "来自子组件的内容1", "msg2": "来自子组件的内容2" }

最新文章

  1. Winform开发框架之读卡器和条码扫描枪的数据接收处理
  2. Android应用主题与横竖屏的切换
  3. Jenkins入门系列之——00答疑解惑
  4. FMDB数据库中的一些操作
  5. php5.3 连接 sqlserver2005
  6. 一句JS搞定只允许输入数字和字母
  7. JavaScript类的设计
  8. 让IE6 IE7 IE8 IE9 IE10 IE11支持Bootstrap的解决方法--(转)
  9. Office2003/2010等集成SP的简单方法
  10. Cmder--cmd的替代工具
  11. Java面试题之Redis
  12. diff比较两个文件 linux
  13. Map集合、HashMap集合、LinkedHashMap集合、Hashtable集合、Collections工具类和模拟斗地主洗牌和发牌
  14. OpenCV LK光流法测试
  15. orcle 如何快速插入百万千万条数据
  16. PySpider问题记录http599
  17. 小峰servlet/jsp(3)登陆功能实现
  18. JAVA中处理事务的程序--多条更新SQL语句的执行(包括回滚)
  19. MemSQL学习笔记-类似MySQL的数据库
  20. socket--接受大数据

热门文章

  1. opencv 图像resize
  2. Xamarin图表开发基础教程(13)OxyPlot框架支持的其它图表
  3. git push ! [rejected] master -&gt; master (non-fast-forward) error: failed to push some refs to &#39;https://github.com/Operater9/guest&#39; hint: Updates were rejected because the tip of your current bra
  4. 运维笔记--给正在运行的Docker容器动态绑定卷组(挂载指定目录)
  5. 浅入深出ETCD之【集群部署与golang客户端使用】
  6. 使用gevent包实现concurrent.futures.executor 相同的公有方法。组成鸭子类
  7. postman传数组参数
  8. LeetCode_482. License Key Formatting
  9. ZYNQ 7020学习笔记之PL侧普通信号中断PS的实验
  10. Difference between java.lang.RuntimeException and java.lang.Exception