通常,插槽內使用的屬性,使用的是引用組件的組件的屬性值。
<template>
<div>
<child v-model="value">
<span>{{value}}</span>
</child>
</div>
</template>
<script>
import child from "./components/child.vue";
export default {
components: {
child: child
},
data() {
return {
value: "132"
};
}
};
</script>
<style>
</style>
<template>
<div :style="style">
<slot></slot>
</div>
</template>
<script>
export default {
data() {
return {
style: {
width: "200px",
height: "200px",
border: "1px solid #ccc"
}
};
}
};
</script>
<style>
</style>