案例代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
<cpn>
</cpn>
<hr>
<cpn>
<span slot="center">标题</span>
<span slot="left">返回</span>
<span slot="right">更多</span>
</cpn>
</div>
<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 src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
const app = new Vue({
el:"#app",
data:{
},
components:{
cpn:{
template:'#cpn'
}
}
})
</script>
</body>
</html>
二丶运行结果
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/31d4c844a43caa16b19fda08fa704d19.png)
——钟鼓馔玉不足贵,但愿长醉不愿醒——