19-作用域插槽的使用
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<script src="js/vue.min.js"></script>
<body>
<div id="app">
<cpn></cpn>
<cpn>
<div slot-scope='slot'>
<span v-for="item in slot.data">{{item}}----</span>
</div>
</cpn>
<cpn></cpn>
</div>
<template id="tem1">
<div>
<slot :data='pLanguages'>
<ul>
<li v-for="item in pLanguages" style="list-style: none;">{{item}}</li>
</ul>
</slot>
</div>
</template>
<script>
const app = new Vue({
el:'#app',
data:{
},
components:{
'cpn':{
template:'#tem1',
data(){
return{
pLanguages:['javascript','python','swift','go','c++']
}
}
}
}
})
</script>
</body>
</html>