• 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;
    }
  • 相关阅读:
    GUC-3 模拟CAS算法
    GUC-2 原子性
    GUC-1 volatile
    NIO-5补充
    NIO-4pipe
    NIO-3网络通信(非阻塞)
    NIO-3网络通信
    NIO-1缓冲区(Buffer)
    NIO-2通道(Channel)
    eclipse安装spring boot插件spring tool suite
  • 原文地址:https://www.cnblogs.com/brucehome/p/3255922.html
Copyright © 2020-2023  润新知