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谢谢你的提示!