admin-vue/10-组件化开发/09-组件插槽使用/01-slot插槽的基本使用.html

58 lines
1.2 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!--
slot插槽使用必须在模板内部有定义slot标签通过使用组件模板传递插槽内容传递过去
-->
<div id="app">
<apps>
<div>这是一个span标签</div>
<span>哈哈哈</span>
</apps>
<apps>
<div>这是一个span标签</div>
<span>呵呵呵</span>
</apps>
<apps>
<div>
<div>这是一个span标签</div>
<span>耶耶耶</span>
</div>
</apps>
<apps></apps>
<apps></apps>
<apps>
<div>这是一个单选框</div>
<input type="radio" name="" id="">
</apps>
</div>
<template id="tpl">
<div>
<div>
<slot>
<div>这是一个按钮</div>
<button>按钮</button>
</slot>
</div>
</div>
</template>
</body>
<script src="../../JavaScript/vue.js"></script>
<script>
new Vue({
el:"#app",
components:{
'apps':{
template:"#tpl",
}
}
})
</script>
</html>