[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属性即可 ...
随机推荐
- 耗时三年开源的H5商城,生产级代码实战
waynboot-mall 商城项目是我从疫情开始初期着手准备开发的,到如今 2023 年底,已经过了 3 年多的时间. 从项目初期到现在,一个人持续迭代,修复漏洞,添加功能,经历了前端开发工具从 v ...
- 聊聊kube-scheduler如何完成调度和调整调度权重
本文分享自华为云社区<kube-scheduler如何完成调度和调整调度权重>,作者: 可以交个朋友. 一.概述 Kube-scheduler作为k8s集群的默认调度器,它监听(watch ...
- bash shell笔记整理——stat命令
stat命令的作用 stat主要用于查看文件的详细信息,包括access time(atime).modify time(mtime).change time.权限.属主.属组等信息 atime:只有 ...
- 字节国际化TnS算法实习的碎碎念
Motivation 在保研之后,我和南大的导师投了一篇个性化联邦学习的CVPR作为毕设.之后感觉就没什么事了,于是想着找个实习吧,第一个想法就是去字节实习,也只投了字节(别学我,还是多投一些哈哈,找 ...
- CVE-2022-39197 复现
CVE-2022-39197 ️漏洞介绍 Cobalt Strike (CS) 是一个为对手模拟和红队行动而设计的平台,相当于增强版的Armitage,早期以Metasploit为基础框架,3.0版本 ...
- OpenSSL命令总结
OpenSSL命令总结 疑今者察之古,不知来者视之往. 导航 介绍 对称加密 公钥加密 信息摘要 数字证书 杂项 介绍 密码学标准和互联网协议一样,是一种大家都遵守的约定和标准,比如PKCS#1中规定 ...
- SQLServer清空数据库日志
-------SQl2008以上 清空日志-------- USE[master] GO ALTER DATABASE [数据库名称] SET RECOVERY SIMPLE WITH NO_WAIT ...
- 25、Flutter中基本路由
Flutter 路由介绍 Flutter中的路由通俗的讲就是页面跳转.在Flutter中通过Navigator组件管理路由导航. 并提供了管理堆栈的方法.如:Navigator.push和Naviga ...
- 仿微信语音聊天webrtc
主要技术 MediaRecorder 录音 webrtc 获取麦克风 URL.createObjectURL 转换为url(实际生产中,通过后端转换blob为mp3网址) 实现elementui+vu ...
- 【Pandas】groupby连用的count()和size()的区别
groupby连用的count()和size()的区别 count() 计算的是 value(数值): size() 计算的是 size(个数) 我们有以下表: size() age = df.gro ...