【发布时间】:2019-08-12 14:43:34
【问题描述】:
当我点击红色按钮时,我应该只在控制台中看到红色而不是灰色。 我怎样才能做到这一点?
import { Component, Input } from '@angular/core';
@Component({
selector: 'hello',
template: `
<button style="height: 100px; width: 200px;" (click)='gray()'> Gray
<button style="height: 20px; width: 40px; background-color:red" (click)='red()'>
Red
</button>
</button>`,
styles: [`h1 { font-family: Lato; }`]
})
export class HelloComponent {
red() {
console.log('red');
}
gray() {
console.log('gray');
}
}
编辑:我已将问题调整为 div 内的按钮
【问题讨论】:
-
无论框架如何,将
-
我可以想象一个屏幕阅读器会找出按钮的作用。仅仅因为它有效并不意味着你应该这样做。
标签: angular