具名插槽的使用
作者:互联网
slot 具名插槽的使用
给slot取上别名
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
{{message}}
<cpn>
<span slot="center">搜索信息</span>
</cpn>
</div>
<script src="../vue.js"></script>
<template id="cpn">
<div>
<slot name="left"><span>左边</span></slot>
<slot name="center"><span>中间</span></slot>
<slot name="right"><span>右边</span></slot>
</div>
</template>
<script>
const app = new Vue({
el: '#app',
data: {
message: 'hello'
},
components: {
cpn: {
template: '#cpn'
}
}
})
</script>
</body>
</html>
标签:slot,cpn,插槽,具名,使用,message,app 来源: https://www.cnblogs.com/ch2020/p/14846618.html