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>
热门推荐
1 泰迪狗狗如何训练
3 狗狗训练图
5 狗狗训练方法
6 训练狗狗不咬人
8 敏捷训练狗狗
10 训练狗狗吃饭
11 泰迪狗狗训练
12 狗狗从多大开始训练
13 狗狗训练学校费用
14 怎么去训练狗狗
15 狗狗训练狗狗
16 狗狗训练教程
17 训练狗狗装死
18 泰迪狗狗的训练方法