vue222/10-组件化开发/09-组件插槽使用/03-作用域插槽的使用.html

46 lines
902 B
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
<apps>
<h1>这是父组件</h1>
<div slot-scope="data">
<span v-for="li in data">{{li.join("-")}}</span>
</div>
</apps>
</div>
<template id="tpl">
<div>
<slot :datas="list">
<ul>
<li v-for="item in list">{{item}}</li>
</ul>
</slot>
</div>
</template>
</body>
<script src="../../JavaScript/vue.js"></script>
<script>
new Vue({
el:"#app",
components:{
'apps':{
template:"#tpl",
data(){
return {
list:['这是内容1','这是内容2','这是内容3']
}
}
}
}
})
</script>
</html>