vuejs / Discussion

Vue.js discussion
167 stars 17 forks source link

Conditional rendering and child component #1327

Open wiloke opened 6 years ago

wiloke commented 6 years ago

Hi I'm trying to use v-if with the child components but it's not working. My code:

<wiloke-daily v-if="oData.frequency==='daily'" o-data="{stars: '', openingAt: '', endsOn: '', closedAt: ''}"></wiloke-daily> <wiloke-weekly v-else-if="oData.frequency==='weekly'" o-data="{stars: '', openingAt:'', endson:'', closedAt:'', day: ''}"></wiloke-weekly> <wiloke-occurs-once v-else o-data="{stars: '', openingAt: '', endsOn: '', closedAt: ''}"></wiloke-occurs-once>

but it works if I use div instead of my component

<div v-if="oData.frequency==='daily'">Daily</div> <div v-else-if="oData.frequency==='weekly'">Weekly</div> <div v-else>Occurs Once</div>

I guess the components need to be rendered while mounting, right?