[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属性即可 ...
随机推荐
- Codeforces Round 906 (Div. 2)A-E1
A. Doremy's Paint 3 记数组中数的种类数为\(k\),当\(k=1\)时,答案为\(yes\):当\(k=2\)时,记两个种类的数的个数差为\(d\),当\(d≤1\)时,答案为\( ...
- Tensorflow2.0:使用Keras自定义网络实战
tensorflow2.0建议使用tf.keras作为构建神经网络的高级API 接下来我就使用tensorflow实现VGG16去训练数据 背景介绍: 2012年 AlexNet 在 ImageNet ...
- Netty源码学习9——从Timer到ScheduledThreadPoolExecutor到HashedWheelTimer
系列文章目录和关于我 一丶前言 之前在学习netty源码的时候,经常看netty hash时间轮(HashedWheelTimer)的出现,时间轮作为一种定时调度机制,在jdk中还存在Timer和Sc ...
- vulntarget-c-wp
vulntarget-c 信息收集 扫开的端口有web服务 访问了web页面,发现用的是laravel框架 搜索一下历史漏洞,在gayhub上找到这个可以用,能够执行简单命令 python3 expl ...
- 27、flutter Dialog 弹窗
AlertDialog //放在State<>之下 void _alertDialog() async { var result = await showDialog( barrierDi ...
- 18、Scaffold 布局组件
Scaffold 是一个非常重要的布局组件,它提供了一个常见的应用程序结构布局,包含了许多基础的 UI 元素和交互方式. Scaffold 组件主要由以下几个部分组成: AppBar:用于显示在页面顶 ...
- echarts label formatter params backgroundColor rich 标签设置背景图并传参
小技巧 如果想给label设置背景图,需要使用到rich属性,按照官网示例就可以实现,折线.柱图都一样. 但是大多数情况formatter都是用来通过params里面参数设置自定义的逻辑,如何将两者结 ...
- 教你如何优雅的改写“if-else”
摘要:这些场景,你是怎么写的代码? if-else,这是个再正常不过的coding习惯,当我们代码量小的时候用来做条件判断是再简单不过的了.但对于优秀程序员来说,这却不是好代码. 不信你往下看- 1. ...
- ModelArts的雪中送炭,让我拿下CCF BDCI华为Severless工作负载预测亚军
摘要: 中国计算机学会大数据与计算智能大赛(CCF BDCI)华为Severless工作负载预测亚军方案和ModelArts使用体验分享 本文分享自华为云社区<免费薅ModelArts算力资源- ...
- Python 绑定:从 Python 调用 C 或 C++
摘要:您是拥有想要从 Python 中使用的C或 C++ 库的 Python 开发人员吗?如果是这样,那么Python 绑定允许您调用函数并将数据从 Python 传递到C或C++,让您利用这两种语言 ...