Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nativescript 7有合适的下拉菜单吗?_Nativescript - Fatal编程技术网

Nativescript 7有合适的下拉菜单吗?

Nativescript 7有合适的下拉菜单吗?,nativescript,Nativescript,我正在为nativescript下拉菜单寻找一个开源NS7替代品。有人有什么建议吗。我正在将我的应用程序移植到NS7,但很难找到付费版本插件的替代品。我的解决方法是打开一个包含下拉项的模式,然后在closeCallback函数中接收所选项,如下所示: dropdown-modal.xml 注意Android和iOS类之间的区别。这使下拉列表更像系统 下拉菜单-modal.js 从“/dropdownview model”导入{dropdownview model}”; export cons

我正在为nativescript下拉菜单寻找一个开源NS7替代品。有人有什么建议吗。我正在将我的应用程序移植到NS7,但很难找到付费版本插件的替代品。

我的解决方法是打开一个包含下拉项的模式,然后在
closeCallback
函数中接收所选项,如下所示:

dropdown-modal.xml


注意Android和iOS类之间的区别。这使下拉列表更像系统

下拉菜单-modal.js

从“/dropdownview model”导入{dropdownview model}”;
export const onshownodaly=函数(args){
const dropDownViewModel=新的dropDownViewModel(args.context.title、args.context.list、args.closeCallback);
const page=args.object;
page.bindingContext=dropDownViewModel;
};
下拉列表-view-model.js

从“@nativescript/core”导入{observeable,observearray}”;
导出类DropDownViewModel扩展了Observable{
构造函数(标题、项、关闭回调){
超级();
this.title=标题;
this.data=新的可观测日(项目);
this.selectedItem='';
this.closeCallback=closeCallback;
}
MTAP(args){
this.selectedItem=args.view.bindingContext;
this.closeCallback(this.selectedItem);
}
}
这就是在另一页中的调用方式

sample-page.xml


请注意
dataListId
dataName
dataTitle
是如何传递的

示例-page.js

从“/sample page view model”导入{SamplePageViewModel};
const samplePageViewModel=新samplePageViewModel();
export const onNavigationTo=异步函数(args){
等待samplePageViewModel.populateRolesList();
};
导出const onNavigatedTo=异步函数(args){
const page=args.object;
page.bindingContext=samplePageViewModel;
};
sample-page-view-model.js

从“@nativescript/core”导入{Frame,Observable}”;
从“~/services/LookupService”导入{LookupService};
从“~/utilities/AppSettingSutibility”导入{AppSettingSutibility};
导出类SamplePageViewModel扩展了Observable{
构造函数(){
超级();
this.lookupService=新的lookupService();
this.appsettingsutibility=新的appsettingsutibility();
this.routes=this.appsettingsutibility.getRoutes();
this.roles=[];
this.role={代码:0,值:''};
}
异步populateRolesList(){
this.set('roles',等待此.lookupService.getRoles();//假定角色列表
}
切换下拉列表(args){
const page=args.object.page;
常数=this;
常量选项={
上下文:{title:args.object.dataTitle,list:that.get(args.object.dataListId)},
closeCallback:(selectedItem)=>{
如果(选择编辑项)
set(args.object.dataName,selectedItem);
}
};
page.showmodel(this.routes.dropdown,options);
}
}