【发布时间】:2018-12-11 09:46:04
【问题描述】:
我有两个组件
child-component.vue
<template>
<div class="container">
<slot>
</div>
</template>
父组件.vue
<template>
<my-component>
<input type="text" v-model="myinput1">
<input type="text" v-model="myinput2">
<input type="text" v-model="myinput3">
</my-component>
</template>
<script>
export default {
data() {
return {
myinput1: '',
myinput2: '',
myinput3: '',
}
}
}
</script>
我需要直接从子组件设置槽内每个输入字段的值(输入字段的数量可能会改变)。
有没有办法在不触发子组件事件的情况下实现它?
谢谢
【问题讨论】:
-
你看过Scoped Slots吗?
-
@Beau 是的,但是在我的情况下如何使用它们?
标签: vue.js vuejs2 vue-component