mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
refactor: set selectedIndex = 3 of list-picker (#5008)
* refactor: set selectedIndex = 3 of list-picker * refactor: list-picker.ts * refactor: list-picker.xml * fix: remove ios import
This commit is contained in:
@ -1,7 +1,13 @@
|
|||||||
|
import { ListPicker } from "tns-core-modules/ui/list-picker";
|
||||||
|
import { Page } from "tns-core-modules/ui/page";
|
||||||
|
|
||||||
export function loaded(args) {
|
export function loaded(args) {
|
||||||
var items = [];
|
const items = [];
|
||||||
for (var i = 0; i < 100; i++) {
|
for (var i = 0; i < 100; i++) {
|
||||||
items.push("name" + i);
|
items.push("name" + i);
|
||||||
}
|
}
|
||||||
args.object.bindingContext = { items: items };
|
|
||||||
}
|
const target = (<Page>args.object.page).getViewById<ListPicker>("target");
|
||||||
|
target.items = items;
|
||||||
|
target.selectedIndex = 3;
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<Page loaded="loaded">
|
<Page loaded="loaded">
|
||||||
<StackLayout>
|
<StackLayout>
|
||||||
<ListPicker items="{{ items }}" style="color: deeppink; background-color:lightskyblue" />
|
<ListPicker id="target" items="{{ items }}" style="color: deeppink; background-color:lightskyblue" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</Page>
|
</Page>
|
||||||
|
Reference in New Issue
Block a user