繁体   English   中英

Aurelia简单绑定不起作用

[英]Aurelia simple binding is not working

我有一个非常简单的绑定,它无法正常工作:

app.js:

export class PupilsViewer {

    pupilsInfo = [
        { name: 'John' },
        { name: 'Eric' },
        { name: 'Martin' },
        { name: 'Simon' }
    ];

}

app.html:

<template>
    <require from="./pupil"></require>
    <pupil repeat.for="pupilInfo of pupilsInfo" info="${pupilInfo}"></pupil>
</template>

student.js:

import {bindable} from 'aurelia-framework';

export class Pupil {
    @bindable info = { name: 'unknown' };
}

student.html:

<template>
    <div>Name: ${info.name}</div>
</template>

结果为以下输出:

名称:不明
名称:不明
名称:不明
名称:不明

虽然我曾期望:

姓名:约翰
姓名:埃里克
姓名:马丁
姓名:西蒙

现在我有同样的问题。 这似乎是一个错字问题。 尝试更改或删除可绑定内容的驼峰式保护套。 但您的绑定也不行。

export class PupilsViewer {

    pupils = [
        { name: 'John' },
        { name: 'Eric' },
        { name: 'Martin' },
        { name: 'Simon' }
    ];

}

app.html

<template>
    <require from="./pupil"></require>
    <pupil repeat.for="pupil of pupils" info.bind="pupil"></pupil>
</template>

student.js

import {customElement, bindable} from 'aurelia-framework';

@customElement('pupil')
@bindable('info')
export class Pupil {

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM