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