vue 3个插槽示例(具名插槽)
<div id="app"> <cpn><span slot="center">replace the middle slot</span></cpn> <cpn><span slot="left">replace the left slot</span></cpn> </div> <template id="cpn"> <div> <slot name="left"><span>left</span></slot> <slot name="center"><span>middle</span></slot> <slot name="right"><span>right</span></slot> </div> </template> <script src="https://cdn.jsdelivr.net/npm/vue"></script> <script> const app = new Vue({ el:'#app', data:{ }, methods:{ btnclick(){ } }, components:{ cpn:{ template:'#cpn' } } }) </script>