我尝试在生产模式(devMode:生产)下构建我的 Aurelia 应用程序。构建成功,但是当通过打开 index.html 运行它时,出现错误“无法确定对象的默认视图策略”。
该应用程序在开发模式下构建并通过打开index.html或执行“au run”在本地运行时运行得很好。
该应用程序由 Aurelia-cli 生成。我尝试关闭 webpack.config.js 中为生产模式设置的每个设置,但没有任何运气。
在我的主应用程序视图模型中,我创建了一个视图模型数组,这些视图模型将在视图中用于创建子组件:
应用程序.ts
...
let newBayViewModel = new bay(sectionListLeftBay);
this._bayViewModels.push(newBayViewModel);
newBayViewModel = new bay(sectionListRightBay);
this._bayViewModels.push(newBayViewModel);
...
Run Code Online (Sandbox Code Playgroud)
应用程序.html
<div class="bay" repeat.for="bay of bayViewModels">
<compose view-model.bind="bay"></compose>
</div>
Run Code Online (Sandbox Code Playgroud)
在海湾类中,我创建了一个剖面视图模型数组,这些模型将在海湾视图中界定:
湾.ts
export class bay {
private _sectionViewModels: section[] = [];
public get sectionViewModels() : section[] {
return this._sectionViewModels;
}
constructor(
private _sectionList: string[]) {
this._sectionList.forEach(sectionName => {
let newSectionViewModel = new section(sectionName);
this._sectionViewModels.push(newSectionViewModel);
});
}
}
Run Code Online (Sandbox Code Playgroud)
湾.html
<template>
<div class="section-header" repeat.for="section of sectionViewModels"> …Run Code Online (Sandbox Code Playgroud)