阅读这篇文章: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. HBase应用方案

    HBase性能优化方法:

  2. Stream API学习笔记

    Java8 中Stream API介绍   Stream 使用一种类似用 SQL 语句从数据库查询数据的直观方式来提供一种对 Java 集合运算和表达的高阶抽象.这种风格将要处理的元素集合看作一种流, ...

  3. 【eBPF-01】初见:基于 BCC 框架的第一个 eBPF 程序

    闲言少叙,本文记录了如何零基础通过 BCC 框架,入门 eBPF 程序的开发,并实现几个简易的程序. 有关 eBPF 的介绍,网络上的资料有很多,本文暂且先不深入讨论,后面会再出一篇文章详细分析其原理 ...

  4. 安装华企盾DSC加密软件,USB、银行key等驱动加载不了常见处理方法

    1.首先打开高级客户端查看客户端的权限是否正确 2.将USB设置成放行 3.修改USB管控的注册表 4.安装6.6.0高版本,并添加便捷式设备的注册表改为1见下图 5.添加flag000如正常则把相关 ...

  5. Ascii字符画 在线生成工具

    英文 http://patorjk.com/software/taag/ 点击 Test All 一键测试所有样式 目前有317种可选 个人常用格式 3D-ASCII ANSI Shadow Bulb ...

  6. C++ Qt开发:Charts绘制各类图表详解

    Qt 是一个跨平台C++图形界面开发库,利用Qt可以快速开发跨平台窗体应用程序,在Qt中我们可以通过拖拽的方式将不同组件放到指定的位置,实现图形化开发极大的方便了开发效率,本章将重点介绍TreeWid ...

  7. 【大语言模型基础】60行Numpy教你实现GPT-原理与代码详解

    写在前面 本文主要是对博客 https://jaykmody.com/blog/gpt-from-scratch/ 的精简整理,并加入了自己的理解. 中文翻译:https://jiqihumanr.g ...

  8. Bean named ‘xxxxxx‘ is expected to be of type ‘x‘ but was actually of type ‘com.sun.proxy.$Proxy112‘

    Bean named 'instanceService' is expected to be of type 'awb.operations.service.instance.InstanceServ ...

  9. macOS 安装 clang-tidy

    先安装 homebrew,网上教程很多,推荐官方教程,此处略过 通过 brew 安装 llvm brew install llvm 创建软连接,指向 homebrew 安装的 clang-tidy m ...

  10. Cesium案例解析(八)——CesiumWidget简化窗体

    目录 1. 正文 2. 参考 1. 正文 Cesium Widget这个案例展示了一个Cesium的简化窗体.在之前的案例中使用的都是Cesium.Viewer这个窗体组件,包含了非常丰富的组件内容. ...