【发布时间】:2018-06-09 00:56:04
【问题描述】:
有一个例子
@Component({
selector: 'my-app',
template: `
<div>
<h2 style="background-color:green">
No Filter
</h2>
</div>
<div style="filter:brightness(0.5)">
<h2 style="background-color:green">
Filter with style.
</h2>
</div>
<div [style.filter]="'brightness(' + val + ')'">
<h2 style="background-color:green">
Filter with style binding.
</h2>
</div>
<p>filter binding express value: {{'brightness(' + val + ')'}}</p>
`,
})
export class App {
val = 0.5;
}
https://plnkr.co/edit/gD9xkX5aWrdNDyD6fnIh?p=preview
得到渲染结果:
似乎样式绑定 [style.filter] 不起作用。有人知道原因或提供另一种方法来通过组件成员值控制过滤器亮度样式吗?
感谢您的任何回答!
【问题讨论】:
-
[style.box-shadow] 也不起作用。 Angular 样式绑定是否只支持有限的 CSS 类型?我在 Angular 官网或谷歌上找不到相关文档。