zoukankan      html  css  js  c++  java
  • knockout computed实例

    function Privilege(options) {
        var self = this;
        self.fieldId = options.fieldId;
        self.readAccessType = ko.observable(options.readAccess);
        self.writeAccessType = ko.observable(options.writeAccess);
        self.readAccess = ko.computed({
            read: function () {
                return this.readAccessType() == 1;
            },
            write: function (value) {
                if (value == true) {
                    this.readAccessType(1);
                } else {
                    this.readAccessType(2);
                }
            },
            owner: this
        });
        self.readDeny = ko.computed({
            read: function () {
                return this.readAccessType() == 0;
            },
            write: function (value) {
                if (value == true) {
                    this.readAccessType(0);
                } else {
                    this.readAccessType(2);
                }
            },
            owner: this
        });
    
        self.writeAccess = ko.computed({
            read: function () {
                return this.writeAccessType() == 1;
            },
            write: function (value) {
                if (value == true) {
                    this.writeAccessType(1);
                } else {
                    this.writeAccessType(2);
                }
            },
            owner: this
        });
        self.writeDeny = ko.computed({
            read: function () {
                return this.writeAccessType() == 0;
            },
            write: function (value) {
                if (value == true) {
                    this.writeAccessType(0);
                } else {
                    this.writeAccessType(2);
                }
            },
            owner: this
        });
        return self;
    }
  • 相关阅读:
    CCF-CSP的第三题们么
    STL
    信息安全-期末复习
    NLP自然语言处理
    python 处理文件
    信息安全-简易的DES加解密--3DES
    试药的常见问题
    关于试药的那些事
    Excel的单列和多列的拆分与合并
    Excel中的文本提取操作
  • 原文地址:https://www.cnblogs.com/brucehome/p/3255922.html
Copyright © 2011-2022 走看看