[Vue] Computed property "XXX" was assigned to but it has no setter.
阅读这篇文章:https://blog.csdn.net/weixin_34090562/article/details/91369638
全选,通过计算属性计算得来。结果报错Computed property "XXX" was assigned to but it has no setter.

1 // 总的全选
2 handleSelectAllClassfiy(val) {
3 if (val) {
4 for (let i = 0; i < this.tabledata.length; i += 1) {
5 this.tabledata[i].mychecked = true;
6 this.firstChanged(i); // 调用一级change事件
7 }
8 } else {
9 for (let i = 0; i < this.tabledata.length; i += 1) {
10 this.tabledata[i].mychecked = false;
11 this.firstChanged(i); // 调用一级change事件
12 }
13 }
14 },
除了获取计算属性的值,还可以设置计算属性的值,并且在设置过程中做一些操作。实现这一点需要将计算属性由函数改为带有get和set属性的对象。
解决方法:
1 allChecked: {
2 get () {
3 let count = 0;
4 for (let i = 0; i < this.tabledata.length; i += 1) {
5 if (this.tabledata[i].mychecked === true) {
6 count += 1;
7 } else {
8 count -= 1;
9 }
10 }
11 if (count === this.tabledata.length) {
12 return true;
13 }
14 return false;
15 },
16 set (val) {
17 return val;
18 }
19 }
[Vue] Computed property "XXX" was assigned to but it has no setter.的更多相关文章
- vue报类似警告Computed property "isLoading" was assigned to but it has no setter
一.原因:一个计算属性,当计算传入的是一个函数,或者传入的是一个对象,而没有设置 setter,也就是 set 属性,当你尝试直接该改变这个这个计算属性的值,都会报这个警告,vuex还会出现通过com ...
- vue store获取值时 Computed property "activeTag" was assigned to but it has no setter.
出现原因: element-ui中 el-tab绑定的值在切换tab时会自动修改 而activeTag是从store中获取的值,不能直接修改 要添加给它绑定上set <el-tabs cla ...
- Vue——解决报错 Computed property "****" was assigned to but it has no setter.
在最近的项目中遇到了如下的警告信息: [Vue warn]: Computed property " currentStep" was assigned to but it has ...
- vue computed实现原理
在 Vue.prototype._init 方法中的 initState 中有一个对于computed 的判断,如果有则执行 initComputed 方法初始化 computed. function ...
- vuex bug & vue computed setter
vuex bug & vue computed setter https://vuejs.org/v2/guide/computed.html#Computed-Setter [Vue war ...
- [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
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent c ...
- vue报错 [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
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent c ...
- 深入理解 Vue Computed 计算属性
Computed 计算属性是 Vue 中常用的一个功能,我们今天来说一下他的执行过长 拿官网简单的例子来看一下: <div id="example"> <p> ...
- vue computed 源码分析
我们来看看computed的实现.最简单的一个demo如下: <html> <head> <meta http-equiv="Content-Type" ...
- JSON: Property 'xxx' has no getter method的解决办法
在使用JSONArray.fromObject时候出现JSONException:Property 'xxx' has no getter method. 解决办法:设置bean为public属性即可 ...
随机推荐
- TIOBE 12月榜单: C# 即将成为2023 年度编程语言
TIOBE 公布了 2023 年 12 月的编程语言排行榜. 2022年C# 在挑战成为年度编程语言,但在最后一刻,C++出人意料地夺得了冠军.今年,我们确信 C# 将获胜成为2023年度编程语言.它 ...
- lua完整学习笔记
lua注释 -- 单行注释 --[[ 多行注释 ]]-- lua数据结构 nil 无效值与Java的Null类似,但是在条件表示中是false boolean 布尔值,tu ...
- MySQL索引命名规范
[强制]主键索引名为 pk_字段名:唯一索引名为 uk_字段名:普通索引名则为 idx_字段名 说明:pk_ 即 primary key:uk_ 即 unique key:idx_ 即 index 的 ...
- 印能捷添加了加密进程导出的pdf文件不加密(rename的类型未添加)
解决方法:用procmon监控下图的所有文件事件,查找rename的类型,然后右键SetRenameInfo点击Include,将查出来的类型添加到加密后缀中,如下图是一个无后缀的类型需要添加\NOE ...
- MagicArray基本使用方法
MagicArray致力于让研发不再卷,这个灵感来源于php语言,可能多少年以后,php可能不会有太多人记得.但是在一个年代里,如果论坛里里常见最火爆的帖子无疑是:php是世界上最好的编程语言.由此可 ...
- 从零玩转Websocket实时通讯服务之前后端分离版本
前言 公司项目需要用到消息提示,那么WebSocket它来了经过我面向百度的学习,废话不多说直接开干. 后端搭建 一.依赖导入 <dependency> <groupId>or ...
- win10 安装 AutoCAD
有些人在 win10 系统下 安装 AutoCAD 会有些小问题,不要担心,根据下面这些图片就可以解决你的问题 答案很简单,就是安装.NET Framework3.5,这里提供一种安装方法供大家参考: ...
- 平衡树——AVL算法
平衡树--AVL算法 平衡树建立在二叉搜索树的基础上,加入了两侧子树大小相对平衡的特性而避免了很多情况下的算法退化.这里AVL算法实现的AVL树就是平衡树的一种. 1.二叉搜索树 在说平衡树之前我们得 ...
- AI 图像自动补全 Uncrop 工具介绍
ClipDrop Uncrop是一款基于AI的图像自动补全工具,由StabilityAI旗下的Clipdrop开发.通过利用StableDiffusionXL开发的算法和深度学习技术,Uncrop可以 ...
- 华为云GaussDB两大数据库通过中国信通院多项评测
摘要:权威认可!华为云GaussDB两大数据库通过中国信通院多项评测. 本文分享自华为云社区<官宣!华为云GaussDB两大数据库通过中国信通院多项评测>,作者: GaussDB 数据库 ...