Aurelia - 在自定义元素中覆盖 css 绑定
Aurelia - Overriding css binding inside custom element
我想要实现的是拥有自定义元素并将 css 从 parent 直接绑定到此元素,但也从自定义元素内部绑定。
parent:
<div>
<custom-element css="height: ${heightProperty}"></custom-element>
</div>
自定义元素:
<template css="width: ${widthProperty}">
</template>
但是width和height属性不会同时绑定。只有最后绑定(更改)的才会生效。但是合并似乎在设置 class 属性 时起作用。那么这个bug是故意的还是故意的?
不确定这是否是正确的方法/这样做的正确方法,但是当您将可绑定的 CSS 属性 添加到您的自定义元素时会发生什么?
像这样:
import { bindable } from 'aurelia-framework';
export class customElement {
@bindable()
css = '';
}
然后在你的 HTML
<template css="width: ${widthProperty} ${css}">
</template>
我想要实现的是拥有自定义元素并将 css 从 parent 直接绑定到此元素,但也从自定义元素内部绑定。
parent:
<div>
<custom-element css="height: ${heightProperty}"></custom-element>
</div>
自定义元素:
<template css="width: ${widthProperty}">
</template>
但是width和height属性不会同时绑定。只有最后绑定(更改)的才会生效。但是合并似乎在设置 class 属性 时起作用。那么这个bug是故意的还是故意的?
不确定这是否是正确的方法/这样做的正确方法,但是当您将可绑定的 CSS 属性 添加到您的自定义元素时会发生什么?
像这样:
import { bindable } from 'aurelia-framework';
export class customElement {
@bindable()
css = '';
}
然后在你的 HTML
<template css="width: ${widthProperty} ${css}">
</template>