error Unexpected mutation of "data" prop vue/no-mutating-props
一般情况下 出现此报错 是修改了 父组件的值
即 – 对 prop 的内容进行了修改
但是我的代码并没有 直接对 prop 进行修改但是还是报当前错误
报错代码片
git 报错 代码片
.
// An highlighted block
15:30 error Unexpected mutation of "data" prop vue/no-mutating-props
原代码片
以下为源代码 代码片
.
// An highlighted block
<template>
<div>
<el-form-item style="margin-left: 20px;" label-width="130px" label="合计">
<el-input v-model="data.rawTotal" readonly style="width: 100px"></el-input>
</el-form-item>
</div>
</template>
<script lang="tsx" setup>
const Props = defineProps({
sourceType: {
type: String,
default: ()=>{
return "detail"
}
},
data: {
type: Object,
default: ()=>{
return {}
}
}
});
const dataForm: IObject = computed(() => Props.data);
const data = reactive({
rawTotal: 0, // 合计
});
修改代码片
以下为修改代码 代码片
.
// An highlighted block
<template>
<div>
<el-form-item style="margin-left: 20px;" label-width="130px" label="合计">
<el-input v-model="data.rawTotal" readonly style="width: 100px"></el-input>
</el-form-item>
</div>
</template>
<script lang="tsx" setup>
const Props = defineProps({
sourceType: {
type: String,
default: () => {
return "detail";
}
},
info: {
type: Object,
default: () => {
return {};
}
}
});
const dataForm: IObject = computed(() => Props.info);
const data = reactive({
rawTotal: 0, // 合计
});