【发布时间】:2019-06-04 04:05:24
【问题描述】:
使用以下代码:
import { Aurelia } from "aurelia-framework";
export async function configure(aurelia) {
aurelia.use.standardConfiguration().developmentLogging();
await aurelia
.start()
.then(a => a.setRoot())
//.then(a => a.setRoot("app.js", document.body))
.catch(ex => {
document.body.textContent = `Bootstrap error: ${ex}`;
});
}
我收到此错误:
引导错误:错误:未指定应用程序主机。
如果我改用 .then(a => a.setRoot("app.js", document.body)) 而不是 .then(a => a.setRoot()) 一切正常。
在 Aurelias 自己的快速入门指南中,他们使用以下代码:
import {Aurelia} from 'aurelia-framework';
export function configure(aurelia: Aurelia) {
aurelia.use.basicConfiguration();
aurelia.start().then(() => aurelia.setRoot());
}
如果我在代码中切换到use.basicConfiguration,我仍然会遇到同样的错误。
https://aurelia.io/docs/tutorials/creating-a-todo-app#getting-ready-to-render
要重现的代码沙盒:
【问题讨论】:
-
所写的代码对我来说似乎是正确的。我相信在使用 Webpack 时对
setRoot的空调用不起作用,因为 Webpack 需要您具体说明需要加载哪些模块。如果我不得不猜测,我猜想我们的 CodeSandbox“加载器”的工作方式存在类似的问题。 -
@AshleyGrant 我一开始也怀疑“CodeSandbox loader”。但是我用 Aurelia Script 进行了测试,得到了完全相同的结果。 codesandbox.io/s/lp342n59w7 修改自 aurelia.io/blog/2018/11/04/aurelia-2018-q3-report 的代码。
标签: javascript typescript aurelia codesandbox