vue .sync的使用


在使用vue的. sync中,怎么都用不出來。

出來錯誤:

I Avoid mutating a prop directly since the value will be overuritten whenever the parent component re-renders.

查資料,說的都是vue2以上,取消了.sync..只能在vue1以下用.

可官方的資料中可以用呀: .sync 修飾符.

官方的不可能有問題呀.

於是,按照官方的一步步下去,發現.sync可以使用.但是子組件中要寫,這個一定要寫的,一定要寫一定要寫一定要寫

this.$emit('update:title', newTitle)

title是要在父組件中改變的變量.

這樣一寫的話,在父組件中,引用子組件,.sync就啟作用了

<text-document :title.sync="title"></text-document>

 

I Avoid mutating a prop directly since the value will be overuritten whenever the parent component re-renders.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM