我是靠谱客的博主 凶狠金毛,这篇文章主要介绍解决使用elementUI的el-date-picker报[Vue warn]: Avoid mutating a prop ...Prop being mutated: “placement“的问题,现在分享给大家,希望可以做个参考。

一、错误背景

本人在一个vue2版本中用的elementUI版本是2.15.6

"dependencies": {
        "axios": "0.17.1",
        "element-ui": "^2.15.6",
}

但是使用日期选择时,在控制台报错:

[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: “placement”

found in

  • –> at packages/date-picker/src/picker.vue

报错截图

这种错误一般是因为直接修改了来自于父级的props属性,也就是数据是

可是我这样做后还是报错,通过G搜索,发现了2种解决问题的方式。

二、最简单的解决方式(推荐)

在使用了该组件的自定义标签处添加如下属性placement="bottom-start"即可:

<el-date-picker v-bind="elProps">
    v-model="dateData['value']"
    placement="bottom-start"
</el-date-picker>

三、升级新的elementUI版本到2.15.8

1、在项目package.json中将"element-ui": "^2.15.6"改为"element-ui": "^2.15.8"

2、先卸载之前的版本,再安装新的版本

npm uninstall element-ui
npm install element-ui@2.15.8 -s

最后

以上就是凶狠金毛最近收集整理的关于解决使用elementUI的el-date-picker报[Vue warn]: Avoid mutating a prop ...Prop being mutated: “placement“的问题的全部内容,更多相关解决使用elementUI的el-date-picker报[Vue内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(107)

评论列表共有 0 条评论

立即
投稿
返回
顶部