vue3报错:Uncaught runtime errors: × ERROR this.$set is not a function TypeError: this.$set is not a fu

在这里插入图片描述


报错内容

Uncaught runtime errors: × ERROR this. s e t i s n o t a f u n c t i o n T y p e E r r o r : t h i s . set is not a function TypeError: this. setisnotafunctionTypeError:this.set is not a function at Proxy.editRow (webpack-internal:///./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/basic/component.vue?vue&type=script&lang=js:147:12) at onClick (webpack-internal:///./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[3]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/basic/component.vue?vue&type=template&id=0150519c&scoped=true:582:39) at callWithErrorHandling (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:387:19) at callWithAsyncErrorHandling (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:394:17) at emit (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:5828:5) at eval (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:7301:45) at handleClick (webpack-internal:///./node_modules/element-plus/es/components/button/src/use-button.mjs:73:5) at callWithErrorHandling (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:387:19) at callWithAsyncErrorHandling (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:394:17) at HTMLButtonElement.invoker (webpack-internal:///./node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js:932:83)

解决方法

根据错误信息 this.$set is not a function,可以确定在 Vue 3 中,this.$set 方法已经被移除了。在 Vue 3 中,直接使用 Vue.set 也不再适用,而是推荐使用 Vue.reactive 或直接修改对象属性来触发响应式更新。

为了修复这个问题,可以直接修改 quoteData 数组中的对象属性,而不需要使用 this.$set。以下是具体的修改步骤:
将 方法中的this.$set替换为直接修改对象属性:

editRow(index) {
  this.quoteData[index].editing = true;
},

您好,我是肥晨。
欢迎关注我获取前端学习资源,日常分享技术变革,生存法则;行业内幕,洞察先机。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

奶糖 肥晨

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值