报错

[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop’s value.

问题情形

组件A调用组件B,同时A需要传参给B,B使用props:{}接收参数值。B在修改该参数后出现错误。

报错原因

  • 在 vue1.x 版本中利用 props 的 twoWay 和 .sync 绑定修饰符就可以实现 props 的双向数据绑定。
  • 在 vue2.0 中移除了组件的 props 的双向数据绑定功能,数据只能单向流动,子组件只能被动接收父组件传递过来的数据,并在子组件内不能修改由父组件传递过来的 props 数据。

解决方法

使用$emit让父组件监听到自组件的事件。

子组件事件响应函数:

父组件响应函数:

参考

https://blog.csdn.net/u013948858/article/details/118342541

[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever...相关推荐

  1. 修改props的属性值,Vue warn]: Avoid mutating a prop directly since the value will be overwritten

    在自己写的子组件中加了可以[v-model]的绑定功能,在父组件中使用,出现下面问题: Avoid mutating a prop directly since the value will be o ...

  2. 关于使用elementUI DateTimePicker组件报错[Vue warn]: Avoid mutating a prop directly since the value will be

    报错信息如下: [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the ...

  3. 小前端有话说之:[Vue warn]: Avoid mutating a prop directly since the value will be overwritte父子组件传值问题及sync用法

    相信刚入坑的小前端们在父子组件传值修改的时候或多或少会出现这种警告 警告原因:vue不推荐直接在子组件中修改父组件传来的props的值,会报警告~~ 即通过props传递给子组件的值,不能在子组件内部 ...

  4. el-date-picker报错[Vue warn]: Avoid mutating a prop directly since the value will--解决方法

    在开发的过程中.凡是页面使用了el-date-picker的这个组件 就会报一个这样的错误 从vue的角度来看.是子组件修改了父组件传递过来的参数导致的 但是我改了好久也没改动 后来才发现是eleme ...

  5. vue.runtime.esm.js?2b0e:619 [Vue warn]: Avoid mutating a prop

    问题描述 vue.runtime.esm.js?2b0e:619 [Vue warn]: Avoid mutating a prop directly since the value will be ...

  6. avoid mutating a prop directly since the value will be overwritten whenever完美解决

    在vue父组件传递数据给子组件时候,通过双向绑定给属性赋值时候,报错如下:Avoid mutating a prop directly since the value will be overwrit ...

  7. Avoid mutating a prop directly since the value will be overwritten whenever the parent ...

    错误:[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the paren ...

  8. vue使用prop通信出错:Avoid mutating a prop directly since the value will be overwritten whenever the parent

    使用props进行父子组件通信时产生错误:Avoid mutating a prop directly since the value will be overwritten whenever the ...

  9. vue 报错avoid mutating a prop directly since the value will be overwritten whenever

    这里写自定义目录标题 avoid mutating a prop directly since the value will be overwritten whenever 子组件修改父组件值时报的错 ...

最新文章

  1. 【怎样写代码】工厂三兄弟之抽象工厂模式(六):扩展案例II
  2. Android之ksoap2-android详解与调用天气预报Webservice完整实例
  3. 深度学习时间序列预测:LSTM算法构建时间序列单变量模型预测大气压( air pressure)+代码实战
  4. Linux 批量依赖库拷贝(ldd)
  5. error: ‘__declspec‘ attributes are not enabled; use ‘-fdeclspec‘ or ‘-fms-extensions‘ to enabl
  6. 从Matrix到这个idea
  7. MySQL8.0.14 - 新特性 - InnoDB Parallel Read简述
  8. iOS开发 - StoryBoard + UIScrollView + UIView
  9. 嵌入式Linux USB WIFI驱动的移植
  10. vue 中 computed 计算属性 的用法
  11. focal loss dice loss源码_0815——W2V的TF源码阅读
  12. Java零基础系列001——第一个程序
  13. 有限域f9的特征是多少_第四章有限域1.ppt
  14. 如何在Kubernetes中暴露服务访问 1
  15. win10 java jdk环境变量 配置
  16. 世界著名反垃圾邮件组织的介绍
  17. 实习僧网站信息获取及字体解密
  18. ESXi8.0中NVME硬盘不识别解决方法1,设置直通
  19. 【分享】PPT--你不知道的使用技巧
  20. Winform(C#) 国内开源美化控件主题库3: HZHControls

热门文章

  1. Revit开发读取CAD信息
  2. mysql脚本修改大量数据问题
  3. 冰羚中间件 conceptual-guide.md翻译
  4. RHCA回忆录---RH236介绍
  5. 如何定位在测试中遇到的Bug?
  6. 批量给视频添加背景图片的操作方法
  7. docker超强总结,docker这一篇就够了
  8. 如何使用Node.js来制作电子音乐-编写我们的旋律
  9. stm32的IIC驱动0.96OLED
  10. 【ANSYS】Notepad++:一款好用的APDL语法编辑器