aurelia 绑定样式
示例
使用Aurelia绑定到浏览器本机style属性。如果使用字符串插值,则应使用css别名,以便样式在InternetExplorer中起作用。
样式字符串
export class MyViewModel {
constructor() {
this.styleString= 'color: #F2D3D6; background-color: #333';
}
}<template> <div style.bind="styleString"></div> </template>
样式对象
export class MyViewModel {
constructor() {
this.styles= {color: '#F2D3D6', 'background-color': '#333'};
}
}<template> <div style.bind="styles"></div> </template>
字符串插值
与上面的字符串绑定非常相似,这使您可以使用字符串插值来绑定到样式。如果任何值更改,它们将在视图中进行相应更新。
注意:为了与InternetExplorer兼容,我们使用别名css来绑定样式。这样可以确保在InternetExplorer中进行字符串插值。
export class MyViewModel {
color = 'red';
height = 350;
width = 350;
}<template>
<div css="width: ${width}px; height: ${height}px; color:${color}">My Text</div>
</template>
热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短