2022-11-07 10:18:00 +08:00
|
|
|
<!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>
|
2022-11-19 11:23:13 +08:00
|
|
|
<script src="../../../00-tools/JavaScript/vue.js"></script>
|
2022-11-07 10:18:00 +08:00
|
|
|
<script>
|
|
|
|
new Vue({
|
|
|
|
el:"#app",
|
|
|
|
components:{
|
|
|
|
'apps':{
|
|
|
|
template:"#tpl"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
</html>
|