<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>作用域插槽</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="root">
<child>
<template slot-scope="props">
<li>{{ props.item }}--Q</li>
</template>
</child>
</div>
<script>
Vue.component('child',{
data(){
return {
list:[1,2,3,4]
}
},
template:`<ul>
<slot v-for="item of list" :item=item></slot>
</ul>`
});
let vm = new Vue({
el: '#root',
})
</script>
</body>
</html>
Vue2.x之作用域插槽
猜你喜欢
转载自blog.csdn.net/qq_33733970/article/details/80642913
今日推荐
周排行