vue222/10-组件化开发/09-组件插槽使用/复习/复习具名插槽的使用.html

52 lines
1.1 KiB
HTML

<!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>
<!--
使用嵌套传递内容到插槽必须将slot属性设置在父元素上
-->
<body>
<div id="app">
<apps>
<input type="text" name="" id="" placeholder="左边" slot="left">
<label for="" slot="mid">中间</label>
<div slot="right">
<input type="text" name="" id="" placeholder="右边" >
<input type="checkbox" name="" id="">
</div>
</apps>
<br>
<apps></apps>
</div>
<template id="tpl">
<div>
<slot name="left">
<input type="button" value="左边">
</slot>
<slot name="mid">
<input type="button" value="中间">
</slot>
<slot name="right">
<input type="button" value="右边">
</slot>
</div>
</template>
</body>
<script src="../../../00-tools/JavaScript/vue.js"></script>
<script>
new Vue({
el:"#app",
components:{
'apps':{
template:"#tpl"
}
}
})
</script>
</html>