0
我试图用NativeScript做一些实验,但我面临一些奇怪的错误,我不明白这一点。Nativescript和ListView,项目undefined
我米有小宠物的简单列表我的组件里面:
import {Component} from '@angular/core';
import {Http} from '@angular/http';
@Component({
selector:'pokemon-list',
templateUrl: 'components/pokemonList/pokemonList.html'
})
export default class PokemonList {
pokemons: Array<any>;
constructor(private http:Http){
this.pokemons = [
{name: 'Bulbi', url: 'google.com'}
];
}
}
并具有相关的下面的模板:
<StackLayout>
<Label text="Pokemons" class="h1 text-center"></Label>
<ListView [items]="pokemons">
<template let-item="pokemon">
<pokemon-item [name]="pokemon.name" [url]="pokemon.url"></pokemon-item>
</template>
</ListView>
</StackLayout>
当我尝试启动应用程序,我有在我的控制台中出现以下错误:
Error in components/pokemonList/pokemonList.html:4:20 caused by: undefined is not an object (evaluating 'self.parentView.context.pokemon.name')
我在做什么错? :/
它听起来完全听起来很奇怪,NativeScript没有多大帮助,因为它们的默认示例是'let-item =“item”',这让我觉得语法是'let-项= “myCustomName”'。感谢您的澄清! –