<! DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<title>Slot content distribution</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
<my-hello>
<ul slot="s2">
<li>aa</li>
<li>bb</li>
<li>cc</li>
</ul>I am the content of the component that needs to be displayed extra<ul slot="s1">
<li>1222</li>
<li>1222</li>
<li>1222</li>
</ul>
</my-hello>
</div>
<template id="hello">
<div>
<slot name='s1'>If there is no content, display it</slot>
<h3>welcome to itapp</h3>
<slot>If there is no content, display it</slot>
<slot name='s2'>If there is no content, display it</slot>
</div>
</template>
<script>
var vm=new Vue({
el:'#app'.components: {'my-hello': {template:'#hello'}}});</script>
</body>
</html>
Copy the code