我安装了 aurelia-dialog npm install aurelia-dialog --save
。哪个安装的版本"version": "2.0.0-rc.3"
。我通过.plugin(PLATFORM.moduleName('aurelia-dialog')) ;
在配置函数中添加 aurelia.use 来修改 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+"]");
});
}
我的关系虚拟机:
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>
评论中的所有内容,但如果没有这个,它的工作方式就不一样了:(
当我单击按钮测试(请参阅导入类)时,没有任何附加内容,并且我有这些痕迹:
致命: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
未处理的拒绝错误:BindingLanguage 必须实现 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-
对话框/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 博客或其他任何地方都找不到任何答案...