[英]Aurelia simple binding is not working
I have a very simple binding which isn't working as I'd expect it to: 我有一个非常简单的绑定,它无法正常工作:
app.js: app.js:
export class PupilsViewer {
pupilsInfo = [
{ name: 'John' },
{ name: 'Eric' },
{ name: 'Martin' },
{ name: 'Simon' }
];
}
app.html: app.html:
<template>
<require from="./pupil"></require>
<pupil repeat.for="pupilInfo of pupilsInfo" info="${pupilInfo}"></pupil>
</template>
pupil.js: student.js:
import {bindable} from 'aurelia-framework';
export class Pupil {
@bindable info = { name: 'unknown' };
}
pupil.html: student.html:
<template>
<div>Name: ${info.name}</div>
</template>
This results in the following output: 结果为以下输出:
Name: unknown
名称:不明
Name: unknown名称:不明
Name: unknown名称:不明
Name: unknown名称:不明
whilst I'd have expected: 虽然我曾期望:
Name: John
姓名:约翰
Name: Eric姓名:埃里克
Name: Martin姓名:马丁
Name: Simon姓名:西蒙
right now i had the same problem. 现在我有同样的问题。 it seems to be a typo-problem.
这似乎是一个错字问题。 try to change or remove camel-case for your bindables.
尝试更改或删除可绑定内容的驼峰式保护套。 but your binding is also not ok.
但您的绑定也不行。
export class PupilsViewer {
pupils = [
{ name: 'John' },
{ name: 'Eric' },
{ name: 'Martin' },
{ name: 'Simon' }
];
}
app.html app.html
<template>
<require from="./pupil"></require>
<pupil repeat.for="pupil of pupils" info.bind="pupil"></pupil>
</template>
pupil.js student.js
import {customElement, bindable} from 'aurelia-framework';
@customElement('pupil')
@bindable('info')
export class Pupil {
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.