【发布时间】:2017-03-22 01:44:08
【问题描述】:
在 angular2 和 reactjs 中做了一些小应用程序之后,这是我第一次尝试使用 Aurelia。 在快速启动之后,我的第一个应用程序出现错误,只是更新应用程序以显示“hello world”:
http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/quick-start/1
我有一个错误:
未捕获(承诺中)错误:在模块“src/app”中找不到视图模型。 在 aurelia-core.min.js:7
知道发生了什么吗?我不清楚这个错误; aurelia 管理好错误消息?
“视图模型”是指html模板文件?
/index.html
<!DOCTYPE html>
<html>
<head>
<title>Aurelia</title>
</head>
<body aurelia-app="src/main">
<script src="scripts/system.js"></script>
<script src="scripts/config-typescript.js"></script>
<script src="scripts/aurelia-core.min.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
/src/main.ts
import {Aurelia} from 'aurelia-framework';
export function configure(aurelia: Aurelia) {
aurelia.use.basicConfiguration();
aurelia.start().then(() => aurelia.setRoot());
}
更新:错误是 app.ts 是 app.ts 是空的!
/src/app.ts
export class App {
heading = "Hello World";
}
/src/app.html
<template>
<h1>${heading}</h1>
</template>
【问题讨论】:
-
您可以发布您的 app.ts 文件内容吗?视图模型是 *.ts 文件,视图是 *.html 文件。
-
感谢@Lakerfield,我的错误是我从快速入门网站粘贴 app.ts 内容后没有保存它,内容为空。昨天工作这么晚!
标签: aurelia