Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 改变聚合物的性能值_Javascript_Properties_Polymer_Polymer 2.x_Polymer Elements - Fatal编程技术网

Javascript 改变聚合物的性能值

Javascript 改变聚合物的性能值,javascript,properties,polymer,polymer-2.x,polymer-elements,Javascript,Properties,Polymer,Polymer 2.x,Polymer Elements,我已经申报了这样的财产: static get properties() { return { auth1: { type: Boolean, readonly: false, value: false, notify: true } }; } connect() { th

我已经申报了这样的财产:

static get properties() {
        return {
            auth1: {
                type: Boolean,
                readonly: false,
                value: false,
                notify: true
            }
        };
    }
connect() {
    this.auth1 = true;
    console.log("Authenticated" + this.auth1.value);
}
在我的聚合物元素中。现在我有了这个功能:

connect(){
        this.auth1.value = true;
        console.log("Authenticated" + this.authenticated);

    }
这会将属性值更改为true。每次调用函数时,我都会遇到错误TypeError:试图分配给readonly属性。。但是我在我的属性中将readonly设置为false。我的函数通过如下按钮调用: 点击我


有人能帮我吗

问题在于属性值的更改

相反:

connect(){
        this.auth1.value = true;
        console.log("Authenticated" + this.authenticated);

    }
更改可以如下所示:

static get properties() {
        return {
            auth1: {
                type: Boolean,
                readonly: false,
                value: false,
                notify: true
            }
        };
    }
connect() {
    this.auth1 = true;
    console.log("Authenticated" + this.auth1.value);
}
只读:默认值为false,可以删除

static get properties() {
    return {
        auth1: {
            type: Boolean,
            value: false,
            notify: true
        }
    };
}

有一件事:O应该大写:readOnly:false谢谢你的提示!