[Vuejs]-How to communicate between components and slots?

0👍

Yes you can give slot-scope and you will get the data

In your medical-form component bind your dynamic value.

<slot :dob="dob" />

<medical-form>
    <template slot-scope="{dob}">
     <input type="text" v-model="dob" />
    </slot>
</medical-form>

But recently vue deprecated using of slot-scope but it is backward compatible and will work. However I would like to show you that also.

Reference – https://v2.vuejs.org/v2/guide/components-slots.html

<medical-form>
  <template v-slot="{dob}">
    <input type="text" v-model="dob" />
  </template>
</medical-form>

Leave a comment