我最近升级了Aurelia打字稿/ ASPNETCORE / Webpack项目。我记不清了,但是我想我使用了类似于以下的模板:
https://github.com/vuorinem/aspnet-aurelia-webpack-skeleton
工作出色。但是,升级后,唯一失败的插件是aurelia-validation。这是boot.ts文件:
boot.ts
import 'isomorphic-fetch';
import { Aurelia, PLATFORM } from 'aurelia-framework';
import { HttpClient } from 'aurelia-fetch-client';
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap';
declare const IS_DEV_BUILD: boolean; // The value is supplied by Webpack during the build
export function configure(aurelia: Aurelia) {
aurelia.use
.standardConfiguration()
.plugin(PLATFORM.moduleName('aurelia-validation'))
.plugin(PLATFORM.moduleName('aurelia-cookie'))
.plugin(PLATFORM.moduleName('aurelia-dialog'))
.feature(PLATFORM.moduleName('app/components/common/index'));
if (IS_DEV_BUILD) {
aurelia.use.developmentLogging();
}
new HttpClient().configure(config => {
const baseUrl = document.getElementsByTagName('base')[0].href;
config.withBaseUrl(baseUrl);
});
aurelia.start().then(() => aurelia.setRoot(PLATFORM.moduleName('app/components/app/app')));
}
其他两个插件的行为...但是当“ aurelia-validation”尝试加载时,它会失败:
Uncaught (in promise) Error: Invalid resource path [function ValidateBindingBehavior() {
return _super !== null && _super.apply(this, arguments) || this;
}]. Resources must be specified as relative module IDs.
at FrameworkConfiguration.globalResources (aurelia-framework.js:330)
at Object.configure (aurelia-validation.js:1782)
at aurelia-framework.js:186
当我在aurelia-framwork.js中设置断点时,加载的资源不是字符串。所有其他源均使用该字符串加载。可能是某种类型的打字问题吗?
for (var i = 0, ii = toAdd.length; i < ii; ++i) {
resource = toAdd[i];
if (typeof resource !== 'string') {
====> throw new Error('Invalid resource path [' + resource + ']. Resources must be specified as relative module IDs.');
}
抛出时,资源的评估为: Function - not a string