0
我跟着這個doc,但圖像不顯示在用戶界面上。我需要使用複選框,我讀到它應該在圖像的幫助下完成。所以我的複選框圖像沒有出現。我在哪裏做錯了?圖片無法加載Angular 2
import {Component, EventEmitter} from '@angular/core';
import {NS_ROUTER_DIRECTIVES} from 'nativescript-angular/router';
import {APP_ROUTER_PROVIDERS} from "../app.routes"
import ImageModule = require("ui/image");
var ImageSourceModule = require("image-source");
var image = new ImageModule.Image();
image.imageSource = ImageSourceModule.fromResource("checkbox_checked");
//image.imageSource = ImageSourceModule.fromResource("checkbox_unchecked");
@Component({
selector: "checkbox",
properties: ['checked : checked'],
events: ['tap'],
template: `
<StackLayout backgroundColor="#b3d9ff" width="300" height="550">
<Label style="font-size : 20px" text="Choose contacts to sync"></Label>
<Image
[src]="checked ? 'res://checkbox_checked' : 'res://checkbox_unchecked'"
class="checkbox"
(tap)="onTap()"
dock="left">
</Image>
</StackLayout> `
})
export class SyncComponent{
public tap: EventEmitter<boolean> = new EventEmitter<boolean>();
public checked: boolean = false;
constructor() { }
public onTap(): void {
this.tap.next(this.checked);
}
}
'屬性:'應該是'輸入:'和'事件:'應該是'輸出:'。 「屬性」和「事件」自很長一段時間以來都被棄用了。 –
非常感謝。我對角度很陌生。 我已經取代了他們,但仍然沒有改變。有什麼我仍然失蹤? – kenkulan
我沒有想到這會解決你的問題。我不知道NativeScript。 'res:// ...'URL對我來說很奇怪,但可能是NS特有的 –