nativescript - RadSideDrawer 中不再有 BindingContext 了吗?
问题描述
在 Nativescript 5.x (TypeScript) 中,我已成功使用以下代码将视图模型分配给 RadSideDrawer 的绑定上下文:
import * as app from "@nativescript/core/application";
import { EventData } from "@nativescript/core/data/observable";
import { RadSideDrawer } from "nativescript-ui-sidedrawer";
export function drawerLoaded(args: EventData) {
let sideDrawer = <RadSideDrawer>args.object; <-- compiler error 1
sideDrawer.bindingContext = new MyViewModel();
}
然后我更新到 Nativescript 6.4、TypeScript 2.9.2、RadSideDrawer 8.0.0,然后使用“tns migrate”迁移我的应用程序。
在所有这些更新之后,我得到了一个编译器错误 1:
TS2352:将“View”类型转换为“RadSideDrawer”类型可能是一个错误,因为这两种类型都没有充分重叠。如果这是故意的,请先将表达式转换为“未知”。
SO 用户 Manoj 帮助我解决了这个问题(再次感谢您!)。我当前的代码现在看起来像这样:
export function drawerLoaded(args: EventData) {
let sideDrawer : RadSideDrawer = <RadSideDrawer>(<any>args.object);
sideDrawer.bindingContext = new MyViewModel(); <-- compiler error 2
}
现在我得到编译器错误2。
类型“RadSideDrawer”.ts(2339) 上不存在属性“bindingContext”
突然间 RadSideDrawer 没有绑定上下文了?甚至官方文档也不再提及 BindingContext 属性。这里发生了什么?
解决方案
推荐阅读
- shopify - 修复在 shopify 中删除来自 youtube 视频(如 base.js 等)的未使用 javascript
- ruby - 预期数组中单个数组的排列
- excel - 在没有空字符串附加的情况下,通过 vba 打开文件夹不起作用
- azure - 使用私有 DockerHub 存储库中的 Terraform 在 Azure 上部署容器
- ruby-on-rails - Rails 启动失败 - 未定义符号:pthread_atfork
- android - 使用手机的游戏控制台中的 512x512 图标问题
- sql - Postgres 不正确的行估计
- c# - Entity Framework Core MVC App中的多对多数据绑定
- microservices - 将 SAGA 模式与同步 HTTP 请求一起使用
- c++ - 将 double 更改为 float 给出相同的答案,但比较后输出意外