我有以下问题。
我试图通过读取 json 文件来填充一个简单的选择,然后将任何对象的标题显示为选择内的选项。
当我尝试在 div 元素内显示标题时,代码工作得很好,但不能作为选择。
这是我的代码:
import {inject} from 'aurelia-framework';
import {HttpClient} from 'aurelia-http-client';
@inject(HttpClient)
export class Select{
title = "Title";
images = [];
url = 'http://api.flickr.com/services/feeds/photos_public.gne?tags=rainier&tagmode=any&format=json';
favImage = '';
constructor(http) {
this.http = http;
}
activate() {
return this.http.jsonp(this.url).then(response => {
this.images = response.content.items;
});
}
}
and HTML
<template>
<div>${title}</div>
<div repeat.for="pic of images">${pic.title}</div> //This works just fine
<select value.bind="favImage"> //This doesn't work
<option>Select Picture</option>
<option repeat.for="pic of images" model.bind="pic">${pic.title}</option>
</select>
尝试安装最新的skllyhttps://github.com/aurelia/sculpture-navigation/releases这是 0.13.0。编写相同的代码,它应该可以工作。
确保从 js 文件导出的模型 (viewmodel) 的名称与模板 (html) 文件的名称匹配。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)