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

这篇具有很好参考价值的文章主要介绍了avoid mutating a prop directly since the value will be overwritten whenever完美解决。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

在vue父组件传递数据给子组件时候,通过双向绑定给属性赋值时候,报错如下: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. Prop being mutated: "content"

avoid mutating a prop directly since the value will be overwritten whenever,前端,vue.js,javascript

1、报错详情 [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. Prop being mutated: "items_index"

2、错误原因


改动了子组件中引用的父组件的变量,也就是props中的数据

在Vue2中组件props中的数据只能单向流动,即只能从父组件通过组件的DOM属性attribute传递props给子组件,子组件只能被动接收父组件传递过来的数据,并且在子组件中,不能修改由父组件传来的props数据。

3、解决方案avoid mutating a prop directly since the value will be overwritten whenever


不要直接修改从父组件传过文章来源地址https://www.toymoban.com/news/detail-652217.html

到了这里,关于avoid mutating a prop directly since the value will be overwritten whenever完美解决的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • Custom directive is missing corresponding SSR transform and will be ignored

    最近在给业务组件库集成指令库,将各个项目中常用的指令如一键复制、元素和弹窗拖拽等封装到一起,进行统一发版维护。 业务组件库项目架构采用的是pnpm+vite+vue3+vitepress,其中vitepress主要做组件库文档站点同时展示可交互的组件。 开发运行时指令库demo没有问题,构建编

    2024年02月09日
    浏览(6)
  • Commit cannot be completed since the group has already rebalanced and assign

    Commit cannot be completed since the group has already rebalanced and assign

    这里是说提交commit失败, 因为这个组已经重新分配了 正常情况下, kafka会有一个配置用于设置一条消息的过期时间, 在规定时间内, 如果消费者提交了消费完成的信息, 那么就可以正常的分配下一条记录给消费者, 并且将当前记录的状态记为\\\"已消费\\\"状态, 对消息队列做一个标识

    2024年02月11日
    浏览(9)
  • Your local changes to the following files would be overwritten by checkout

    Your local changes to the following files would be overwritten by checkout

    Git 之 Your local changes to the following files would be overwritten by checkout 今天在切换分支时遇到了这样一个问题: 首先翻译下: Your local changes to the following files would be overwritten by checkout 大致意思就是: 当前分支有未跟踪的文件,checkout会覆盖他们,IntelliJ IDEA 会搁置改变,在那之后

    2024年02月14日
    浏览(38)
  • error: The following untracked working tree files would be overwritten by merge:

    error: The following untracked working tree files would be overwritten by merge: 翻译一下就是: 错误:以下未跟踪的工作树文件将被合并覆盖: 问题分析: 问题出在 Error 所列出的文件在本地的当前分支下未授权给 git 追踪,但同样命名的文件,也即出现在另一个(远程)分支下的同一文件却

    2024年02月11日
    浏览(10)
  • 【warning】UserWarning: The parameter ‘pretrained‘ is deprecated since 0.13 and may be removed

    【warning】UserWarning: The parameter ‘pretrained‘ is deprecated since 0.13 and may be removed

    报错内容: 翻译一下,就是参数列表中的pretrained在新版本中被弃了,要使用weights这个参数。然后教你用新的参数。 就按照watning里写的把models.resnet101()后面的内容重新设置就好。 第一种:weights = models.ResNet101_Weights.DEFAULT 输出结果:  第二种:weights = models.ResNet101_Weights.IMA

    2024年02月13日
    浏览(9)
  • 【Git】error: The following untracked working tree files would be overwritten by checkout

    【Git】error: The following untracked working tree files would be overwritten by checkout

    (注意数据备份) 一个项目由submodule 方式组成了一个主仓库,当在主仓库中修改了多个submodule 的version,同时也修改了一些非submodule 的文件内容。在git add ,git commit ,git push 都成功后,想切换到某个branch(A) 的时候,报出错误error: The following untracked working tree files would be ove

    2024年02月12日
    浏览(8)
  • error: Your local changes to the following files would be overwritten by checkout:

    error: Your local changes to the following files would be overwritten by checkout:

    无意间从同事那里听到stash这个命令。于是想到之前遇到的切换分支时遇到的文件状态的问题,所以花了点时间整理了以下笔记,来加深对此命令的认识。 有时,当你在项目的一部分上已经工作一段时间后,所有东西都进入了混乱的状态, 而这时你想要切换到另一个分支做一

    2023年04月08日
    浏览(8)
  • git报错-Your local changes to the following files would be overwritten by merge:

    有一天我在服务器拉取git仓库的代码时报错如下   大概意思就是试图合并一个分支到你的当前分支,但是在你的当前分支上,有三个 .pyc 文件有本地未提交的修改。这些修改如果进行合并操作,将会被合并过来的分支中的对应文件内容覆盖。 错误信息建议在合并之前,你需

    2024年04月10日
    浏览(13)
  • Git常见报错:Your local changes to the following files would be overwritten by merge

    Git常见报错:Your local changes to the following files would be overwritten by merge

    1、报错原因 该报错在git pull时出现,一句话解释就是你在本地改动了代码但是还没有提交,此时再拉取最新代码,远程代码和你当前的本地代码发生冲突!(注意有冲突时才会提示,如果没有冲突,则git pull成功,因为git pull实质上就是一个远程分支merge到本地分支过程。 2、解

    2024年02月08日
    浏览(8)
  • git pull 报错 error: The following untracked working tree files would be overwritten by merge 解决

    git pull origin master 时提示错误  解决方法: 命令: x-----删除忽略文件已经对git来说不识别的文件 d -----删除未被添加到git的路径中的文件 f -----强制运行

    2024年04月25日
    浏览(17)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包