将自定义元素添加到 aurelia 视图
Adding custom elements to aurelia view
是否可以动态加载自定义元素?
假设我的 viewModel 看起来像这样:
export class MyViewModel {
attached() {
$(".content").prepend("<card></card>");
$(".content").prepend("<otherCard></otherCard>");
}
}
为什么 aurelia 没有渲染我的 "cards"。有什么办法可以实现类似的行为吗?
直接在 HTML
中添加这些卡片效果很好,但我需要一种更加模块化的方法。
谢谢
查看文档中的 <compose view-model="card" />
元素。它应该给你你正在寻找的东西。
是否可以动态加载自定义元素?
假设我的 viewModel 看起来像这样:
export class MyViewModel {
attached() {
$(".content").prepend("<card></card>");
$(".content").prepend("<otherCard></otherCard>");
}
}
为什么 aurelia 没有渲染我的 "cards"。有什么办法可以实现类似的行为吗?
直接在 HTML
中添加这些卡片效果很好,但我需要一种更加模块化的方法。
谢谢
查看文档中的 <compose view-model="card" />
元素。它应该给你你正在寻找的东西。