在使用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.