簡體   English   中英

改變聚合物的特性值

[英]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:試圖分配給只讀屬性”。 但是我在我的媒體資源中將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默認readonly: false ,可以將其刪除。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM