Vue中.sync修飾符

Vue 中 sync的做用雙向綁定

<FatherComponent :a.sync = 'b'>
<FatherComponent />同步

子組件中emit('update:a',...args)的時候,
父組件的b就會同步變化it

 


# 實現了父組件prop 和 子組件prop的雙向綁定。io

 


若是沒有這個語法糖date

須要寫語法

<FatherComponent @update:a='(val )=>(c = val)' :a='c' >
<FatherComponent />di

而後子組件emit('update:a',...args)co

相關文章
相關標籤/搜索