<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>单slot插槽</title>
</head>
<body>
<div id="app">
<children>
<span>注册成功</span>
</children>
</div>
<script src="../js/vue.js"></script>
<script>
let vm = new Vue({
el:'#app',
components:{
children:{
template:'<div><slot><p>默认效果</p></slot>这是子组件</div>'
/*
如果在children中不写span标签,那么slot默认会渲染模板里的内容,
最初在slot标签中的任何内容都被视为备用内容。
备用内容在子组件的作用域内编译,并且只有在父组件为空,
且没有要插入内容时才显示备用内容
*/
}
}
});
</script>
</body>
</html>