阅读这篇文章: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.的更多相关文章

  1. vue报类似警告Computed property "isLoading" was assigned to but it has no setter

    一.原因:一个计算属性,当计算传入的是一个函数,或者传入的是一个对象,而没有设置 setter,也就是 set 属性,当你尝试直接该改变这个这个计算属性的值,都会报这个警告,vuex还会出现通过com ...

  2. vue store获取值时 Computed property "activeTag" was assigned to but it has no setter.

    出现原因: element-ui中 el-tab绑定的值在切换tab时会自动修改 而activeTag是从store中获取的值,不能直接修改 要添加给它绑定上set   <el-tabs cla ...

  3. Vue——解决报错 Computed property "****" was assigned to but it has no setter.

    在最近的项目中遇到了如下的警告信息: [Vue warn]: Computed property " currentStep" was assigned to but it has ...

  4. vue computed实现原理

    在 Vue.prototype._init 方法中的 initState 中有一个对于computed 的判断,如果有则执行 initComputed 方法初始化 computed. function ...

  5. vuex bug & vue computed setter

    vuex bug & vue computed setter https://vuejs.org/v2/guide/computed.html#Computed-Setter [Vue war ...

  6. [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 ...

  7. 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 ...

  8. 深入理解 Vue Computed 计算属性

    Computed 计算属性是 Vue 中常用的一个功能,我们今天来说一下他的执行过长 拿官网简单的例子来看一下: <div id="example"> <p> ...

  9. vue computed 源码分析

    我们来看看computed的实现.最简单的一个demo如下: <html> <head> <meta http-equiv="Content-Type" ...

  10. JSON: Property 'xxx' has no getter method的解决办法

    在使用JSONArray.fromObject时候出现JSONException:Property 'xxx' has no getter method. 解决办法:设置bean为public属性即可 ...

随机推荐

  1. 【UniApp】-uni-app概述

    前言 好,经过我们前面文章的编写,大家可以了解到微信小程序开发相关的知识,了解完了这个微信小程序开发和云开发之后,从这篇文章开始,我再来给大家写一下关于 Uniapp 的知识. 好,开始,那什么是 U ...

  2. [JVM] 应用诊断工具之Fastthread(在线诊断)

    0 序言 背景 近期生产系统遇到了一个线程方面的问题,目前根因已定位到.现将fastthread这一诊断工具做一小结,便于以后快速使用 博主我遇到的线程问题:java.lang.OutOfMemory ...

  3. 实验1:UML与面向对象程序设计原则

    本次实验属于模仿型实验,通过本次实验学生将掌握以下内容: 1.掌握面向对象程序设计中类与类之间的关系以及对应的UML类图: 2.理解面向对象程序设计原则.   [实验任务一]:UML复习 阅读教材第一 ...

  4. KNN算法之KD树(K-dimension Tree)实现 K近邻查询

    KD树是一种分割k维数据空间的数据结构,主要应用于多维空间关键数据的搜索,如范围搜索和最近邻搜索. KD树使用了分治的思想,对比二叉搜索树(BST),KD树解决的是多维空间内的最近点(K近点)问题.( ...

  5. java断言机制(assert)

    java断言机制(assert) 概述 断言使用的时候不是很多,测试时会使用,springboot中也有使用,总的来说断言还是要慎重. 在Java中,同样也有assert关键字,表示断言 在Java中 ...

  6. 学习JVM---入门

    1.JVM体系结构 JVM的位置 JVM体系结构 2.类加载器 双亲委派机制 package java.lang; /** * 测试自定义java.lang.String类能否运行成功 * 体会双亲委 ...

  7. ElasticSearch之Create index API

    创建指定名称的index. 命令样例如下: curl -X PUT "https://localhost:9200/testindex_002?pretty" -H 'Conten ...

  8. Ubuntu安装Maridb 10.5版本

    以20.04版本为例 Ubutun20.04自带源默认安装的mariadb版本为10.3不符合安装zabbix6.0的要求 打开MariaDB的官方网站:https://mariadb.org/mar ...

  9. 干货分享丨玩转物联网IoTDA服务系列六-恒温空调

    摘要:本文主要讲述空调接入到物联网平台后,通过恒温空调控制系统,不论空调是否开机,都可以调整空调默认温度,待空调上电开机后,自动按默认温度调节. 场景简介 通过恒温控制系统,不论空调是否开机,都可以调 ...

  10. 云图说|图解云消息服务KooMessage

    摘要:云消息服务(KooMessage)是提供数字化营销新入口,覆盖全行业.全场景.全终端的一站式富媒体消息服务. 本文分享自华为云社区<[开天aPaaS]图解云消息服务KooMessage&g ...