單擊此按鈕時可以更改按鈕顏色,但如何在單擊時更改文本?Aurelia.js按下按鈕時更改文本值
改變文本從點擊到點擊
的Html:
<button type="button" class="btn ${clicked ? 'btn-danger' : 'btn-primary'}" click.trigger="handleClick()">Click</button>
JS ...
clicked = false;
handleClick(){
this.clicked = !this.clicked; // toggle clicked true/false
return true; // only needed if you want to cancel preventDefault()
}