我安装了aurelia-dialog npm install aurelia-dialog --save
。其中安装了版本"version": "2.0.0-rc.3"
。
我通过在配置函数中向aurelia.use添加.plugin(PLATFORM.moduleName('aurelia-dialog')) ;
来修改main.ts。
我加了
"dependencies": [
{
"name": "aurelia-dialog",
"path": "../node_modules/aurelia-dialog/dist/amd",
"main": "aurelia-dialog",
"resources": ["resources/*.js"]
}
]
在aurelia.json中(因此,我不确定它是否有用)。
然后是一个用于调用对话框的模块:
import {DialogService} from 'aurelia-dialog';
import {Rapport} from '../modal/rapport';
@inject(CssAnimator,
EventAggregator,
Parameters,
Configurator,
NewInstance.of(ValidationController),
Validator,
Router,
NewInstance.of(HttpClient),
DialogService
)
export class Import {
constructor(private cssAnim: CssAnimator,
private ea: EventAggregator,
private params: Parameters,
private conf: Configurator,
private controller: ValidationController,
private validator: Validator,
private router: Router,
private httpClient: HttpClient,
private dialogService: DialogService) {
...
}
...
test(){
let testResponse='{"FATAL":["1 ca craint !", "2","3","4"],"WARN":["w1", "w2","w3"],"INFO":["i1","i2","i3"]}';
this.dialogService.open({
viewModel: Rapport,
model:testResponse
}).whenClosed(reponse => {
console.log("Rapport lu :) + ["+reponse.output+"]");
});
}
我的Rapport VM:
import {inject} from 'aurelia-framework';
import {DialogController} from 'aurelia-dialog';
@inject(DialogController)
export class Rapport {
fatals: string[]=[];
warns: string[]=[];
infos: string[]=[];
constructor(private controller: DialogController) {
controller.settings.centerHorizontalOnly = true;
}
activate(rapportJson) {
let rapport = JSON.parse(rapportJson);
this.fatals = rapport.FATAL;
console.log("fatals :"+this.fatals);
this.warns = rapport.WARN;
console.log("warns :"+this.warns);
this.infos = rapport.INFO;
console.log("infos :"+this.infos);
}
}
我的观点:
<template>
<!-- <ux-dialog> -->
<!-- <ux-dialog-body> -->
<!-- <h2>Erreurs fatales : </h2> -->
<!-- <ul> -->
<!-- <li repeat.for="f of fatals"><span>${f}</span></li> -->
<!-- </ul> -->
<!-- <h2>Avertissements : </h2> -->
<!-- <ul> -->
<!-- <li repeat.for="w of warns"><span>${w}</span></li> -->
<!-- </ul> -->
<!-- <h2>Pour information : </h2> -->
<!-- <ul> -->
<!-- <li repeat.for="i of infos"><span>${i}</span></li> -->
<!-- </ul> -->
<!-- </ux-dialog-body> -->
<!-- <ux-dialog-footer> -->
<!-- <button class="btn btn-success" click.delegate="controller.ok()" >Ok</button> -->
<!-- </ux-dialog-footer> -->
<!-- </ux-dialog> -->
</template>
所有已注释的内容,但如果没有此内容,将无法正常工作:(
当我单击按钮测试(请参阅类Import)时,没有任何追加,并且我有以下痕迹:
致死率:1 ca craint!,2,3,4融洽:27:9
警告:w1,w2,w3和睦:29:9
信息:i1,i2,i3和睦:31:9
调试[模板]导入modal / rapport.html数组[] aurelia-logging-console:20:6
的资源未处理的拒绝错误:绑定语言必须实现inspectTextContent()。
mi@webpack-internal:///./node_modules/aurelia-dialog/node_modules/aurelia-templating/dist/native-modules/aurelia-templating.js:892:9 inspectTextContent@webpack-internal:///./node_modules/aurelia-dialog/node_modules/aurelia-templating/dist/native-modules/aurelia-templating.js:909:5 _compileNode@webpack-internal:///./node_modules/aurelia-dialog/node_modules/aurelia-templating/dist/native-modules/aurelia-templating.js:2824:26 _compileNode@webpack-internal:///./node_modules/aurelia-dialog/node_modules/aurelia-templating/dist/native-modules/aurelia-templating.js:2844:26 compile@webpack-internal:///./node_modules/aurelia-dialog/node_modules/aurelia-templating/dist/native-modules/aurelia-templating.js:2791:5 loadViewFactory/</registryEntry.onReady<@webpack-internal:///./node_modules/aurelia-dialog/node_modules/aurelia-templating/dist/native-modules/aurelia-templating.js:3518:27
来自上一个事件:
loadViewFactory/<@webpack-internal:///./node_modules/aurelia-dialog/node_modules/aurelia-templating/dist/native-modules/aurelia-templating.js:3511:31
来自上一个事件:
loadViewFactory@webpack-internal:///./node_modules/aurelia-dialog/node_modules/aurelia-templating/dist/native-modules/aurelia-templating.js:3493:12 loadViewFactory@webpack-internal:///./node_modules/aurelia-dialog/node_modules/aurelia-templating/dist/native-modules/aurelia-templating.js:617:12 load@webpack-internal:///./node_modules/aurelia-dialog/node_modules/aurelia-templating/dist/native-modules/aurelia-templating.js:4274:14 createController/<@webpack-internal:///./node_modules/aurelia-dialog/node_modules/aurelia-templating/dist/native-modules/aurelia-templating.js:4883:14
来自上一个事件:
createController@webpack-internal:///./node_modules/aurelia-dialog/node_modules/aurelia-templating/dist/native-modules/aurelia-templating.js:4871:12 _createControllerAndSwap@webpack-internal:///./node_modules/aurelia-dialog/node_modules/aurelia-templating/dist/native-modules/aurelia-templating.js:4843:12 compose@webpack-internal:///./node_modules/aurelia-dialog/node_modules/aurelia-templating/dist/native-modules/aurelia-templating.js:4945:14 DialogService.prototype.composeAndShowDialog@webpack-internal:///./node_modules/aurelia-dialog/dist/native-modules/dialog-service.js:79:16 DialogService.prototype.open/openResult<@webpack-internal:///./node_modules/aurelia-dialog/dist/native-modules/dialog-service.js:141:20
来自上一个事件:
DialogService.prototype.open@webpack-internal:///./node_modules/aurelia-
dialog / dist / native-modules / dialog-service.js:131:26
Import.prototype.test@webpack-internal:///import/import:279:9 evaluate@webpack-internal:///./node_modules/aurelia-binding/dist/native-modules/aurelia-binding.js:1578:14 callSource@webpack-internal:///./node_modules/aurelia-binding/dist/native-modules/aurelia-binding.js:5269:18 handleEvent@webpack-internal:///./node_modules/aurelia-binding/dist/native-modules/aurelia-binding.js:5278:5 handleDelegatedEvent@webpack-internal:///./node_modules/aurelia-binding/dist/native-modules/aurelia-binding.js:3353:11
怎么了?我在Aurelia博客或其他任何地方都找不到答案...
答案 0 :(得分:0)
你知道吗?
我做了npm install -g aurelia-cli
;它会更新Aurelia。
在另一个目录中,我做了一个au new
,然后安装了我需要的所有软件包(包括aurelia-dialog)。复制/粘贴先前位置的所有src文件,并且...有效!
因此,如果您在使用Aurelia-dialog(我想还有其他插件)时遇到麻烦,请确保将Aurelia更新到最新版本。希望我浪费时间可以帮助别人不要浪费时间...