【发布时间】:2019-05-16 21:01:57
【问题描述】:
我尝试在生产模式 (devMode:production) 下构建我的 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);
...
应用程序.html
<div class="bay" repeat.for="bay of bayViewModels">
<compose view-model.bind="bay"></compose>
</div>
在海湾类中,我正在创建一组剖面视图模型,这些模型将在海湾视图中界定:
bay.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);
});
}
}
bay.html
<template>
<div class="section-header" repeat.for="section of sectionViewModels">
<compose view-model.bind="section"></compose>
</div>
</template>
如果我删除 bay.ts 中创建剖面视图模型的代码,则不会出现错误,因此问题与该部分有关。可能是什么问题?
我正在使用 aurelia-cli 1.0.0-beta.15、webpack 4.31.0、aurelia-webpack-plugin 4.0.0
【问题讨论】:
-
你能检查一下你在生产构建中是否看到任何错误吗?我怀疑您在 prod build 中遇到了无法确定视图策略的错误。
-
@bigopon 恐怕构建输出没有错误
-
也许是复制品?我认为它不应该失败,但可能会出现一些不同的错误/问题
-
@bigpon 我使用 aurelia-cli 创建了一个新应用程序,结果仍然相同。我想我会尝试将 aurelia-cli 降级到稳定版本,看看结果是否相同。
-
和aurelia-cli 0.35.1一样
标签: typescript webpack aurelia