<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Vue中作用域插槽(slot)</title>
</head>
<body>
<script src="https://vuejs.org/js/vue.js"></script>
<div id="app">
<child>
<template slot-scope="props">
<h3>{{props.hahah}}</h3>
</template>
</child>
</div>
<script>
Vue.component('child',{
template:`<div>
<ul>
<slot v-for="name of list" :hahah="name">{{name}}</slot>
</ul>
</div>`,
data:function(){
return {
list:[1,2,3,4]
}
},
})
var vm=new Vue({
el:'#app',
})
</script>
</body>
</html>