<!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>
<div slot="header">上</div>
<div slot="footer">下</div>
</child>
</div>
<script>
Vue.component('child',{
template:`<div>
<slot name='header'></slot>
<div>hello world</div>
<slot name='footer'></slot>
</div>`
});
let vm = new Vue({
el:'#root',
})
</script>
</body>
</html>
Vue2.x之插槽的使用
最新推荐文章于 2024-05-28 17:25:55 发布