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.

转载于:https://www.cnblogs.com/ztgzlu/p/11142653.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值