更改聚合物中的 属性 值

change property value in polymer

我已经声明了一个 属性 这样的:

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

在我的聚合物元素中。现在我有了这个功能:

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

    }

应将 属性 值更改为 true。每次调用该函数时都会出现错误 "TypeError: Attempted to assign to readonly property."。但是我在 属性 中将 readonly 设置为 false。我的函数是用这样的按钮调用的: <button id="loginbutton" on-tap="connect">Click me!</button>

有人可以帮助我吗?

问题在于 属性 值的更改。

改为:

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

    }

可以这样改:

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

readonly: false 是默认值,可以删除。

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