Object.defineProperty()使用示例


let upload_var = {
    "_upload_sw":0,
}; // 1 为开启可以上传文件 0为关闭不能上传文件

Object.defineProperty(upload_var,'upload_sw', {
    configurable:true,
    set:function(newVal){
        this._upload_sw = newVal;
        if(newVal == 1){
            let submit_button = getIDD("submit_button")
            submit_button.className="upload_button"
            console.log('set:'+this._type)
        }else if(newVal == 0){
            let submit_button = getIDD("submit_button")
            submit_button.className="not_submit_button"
        }
    },
    get:function(){
        return this._upload_sw
    }
})

声明:一代明君的小屋|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - Object.defineProperty()使用示例


欢迎来到我的小屋