<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div id="app">
<lk>{{msg}}</lk>
</div>
<template id="Box">
xxxxxxxxxx
<slot></slot>
<!-- 这个插槽事实上给{{msg}}预留了位置 -->
</template>
</body>
<script src="https://unpkg.com/vue@next"></script>
<script>
const box={
data(){
return {
msg:'1111'
};
},
template:'#Box'
}
const app=Vue.createApp({
data(){
return {
msg:"father"
}
},
components:{
'lk':box,
},
methods:{
clickComponent(){
console.log(this.$refs.ngs.msg);
}
}
}).mount("#app");
</script>
</html>
vue3之插槽可与组件混用
最新推荐文章于 2023-12-23 15:36:06 发布