Aurelia最近增加了对布局的支持,他们大致在文档中解释了这些内容.
然而,虽然我设法让布局本身起作用,但是我不能在布局HTML中使用任何变量,我在Layout-ViewModel中将其作为属性.
MWE:
app.ts
import {Router, RouterConfiguration} from 'aurelia-router';
export class App {
router: Router;
configureRouter(config: RouterConfiguration, router: Router) {
config.map([
{ route: 'hello', layoutViewModel: 'layout/main', moduleId: 'hello/index' },
]);
}
}
Run Code Online (Sandbox Code Playgroud)
布局/ main.ts
export class MainLayout {
heading = 'Hallo Welt';
}
Run Code Online (Sandbox Code Playgroud)
布局/ main.html中
<template>
<h1>${heading}!</h1>
</template
Run Code Online (Sandbox Code Playgroud)
但只有感叹号出现.你有什么想法我做错了什么或我怎么能让它工作?
提前谢谢了!