第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何在angular9中重新分配變量?

如何在angular9中重新分配變量?

呼喚遠(yuǎn)方 2023-04-20 17:15:13
我有一個(gè)調(diào)用ngDoCheck(). 該 func 調(diào)用了幾個(gè)重新分配我的變量的 func。但是變量變化只在函數(shù)中發(fā)生,而不是全局變量。myVariable總是0。myVariable = 0;ngDoCheck(): any {    const word: string = this.form.get('word').value;    this.PasswordStrengthMeter(word, this.myVariable);    console.log('Value: ' + this.myVariable);  }Mainfunc(word: string, myVariable: number): any {    this.SecondaryFunc(word, myVariable);    this.AnotherSecondaryFunc(word, myVariable);      }
查看完整描述

2 回答

?
精慕HU

TA貢獻(xiàn)1845條經(jīng)驗(yàn) 獲得超8個(gè)贊

如果它在同一個(gè)組件中,為什么要將該變量傳遞給每個(gè)函數(shù)?只需在該函數(shù)中使用它,因?yàn)樗且粋€(gè)全局變量。



查看完整回答
反對(duì) 回復(fù) 2023-04-20
?
郎朗坤

TA貢獻(xiàn)1921條經(jīng)驗(yàn) 獲得超9個(gè)贊

的值被myVariable傳遞給Mainfunc,而不是引用。


如果您想更改全局變量,請(qǐng)this.myVariable直接使用您的其他SecondaryFunc和AnotherSecondaryFunc.


myVariable = 0;


...


Mainfunc(word: string): any {

    this.SecondaryFunc(word);

    this.AnotherSecondaryFunc(word);

}


SecondaryFunc(word: string): any {

    this.myVariable = 5;

}


AnotherSecondaryFunc(word: string): any {

    this.myVariable = 6;

}


查看完整回答
反對(duì) 回復(fù) 2023-04-20
  • 2 回答
  • 0 關(guān)注
  • 136 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)