解决[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent

❤️砥砺前行,不负余光,永远在路上❤️ 目录 前言一、使用watch二、 前言 [Vue warn]: Avoid mutating a prop dir

❤️砥砺前行,不负余光,永远在路上❤️

目录

    • 前言
    • 一、使用watch
    • 二、

前言

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

一、使用watch

  watch: {previewList: {handler(val) {console.log(val, 'val');this.fileList = val;},immediate: true,},},

在这里插入图片描述
网上好多说是直接data中赋值给另外一个变量,好像没用,我这直接改previewList的话就会报错,使用watch监听一下然后赋值给fileList就好了,修改的时候直接改fileList就可以。
在这里插入图片描述
在这里插入图片描述

二、