git 提交 报 error Unexpected mutation of “data“ prop vue/no-mutating-props

3 篇文章 0 订阅

一般情况下 出现此报错 是修改了 父组件的值

即 – 对 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,                    // 合计
});

可以看到 我把其中 Props 下的 data 改为了 info 再次提交就可以了!

问题应该出在 ESLint 检测命名上

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
引用:npm ERR! 404 Not Found - GET https://registry.npmmirror.com/@vue/vue-loader-v15 - [NOT_FOUND] @vue/vue-loader-v15 not found vue 安装npm i element-ui -S 等 组件 错 npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmmirror.com/@vue/vue-loader-v15 - [NOT_FOUND] @vue/vue-loader-v15 not found npm ERR! 404 npm ERR! 404 '@vue/vue-loader-v15@15.10.0' is not in the npm registry. npm ERR! 404 You should bug the author to publish it (or use the name yourself!) npm ERR! 404 It was specified as a dependency of '@vue/cli-service' npm ERR! 404 npm ERR! 404 Note that you can also install from a npm ERR! 404 tarball, folder, http url, or git url. 根据引用的内容,这个错误是由于找不到vue-awesome-swiper的tarball数据所导致的。vue-awesome-swiper的tarball数据位于http://172.168.251.67:4873/vue-awesome-swiper/-/vue-awesome-swiper-3.1.3.tgz。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [npm install -g cnpm --registry=https://registry.npm.taobao.org错](https://blog.csdn.net/qq_36853469/article/details/99900961)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [ist的matlab代码-gitlab-uberspace-tutorial:如何在https://uberspace.de上安装GitLab](https://download.csdn.net/download/weixin_38543120/19078868)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [ 404 Not Found - GET https://registry.npmmirror.com/@vue%2fvue-loader-v15 - [NOT_FOUND] @vue](https://blog.csdn.net/qq_51307593/article/details/127484795)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值