如何从页面访问 RadSideDrawer? [英] How to access RadSideDrawer from page?

查看:67
本文介绍了如何从页面访问 RadSideDrawer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Nativescript 5.x (TypeScript) 中,我已成功使用以下代码访问 RadSideDrawer:

In Nativescript 5.x (TypeScript) I have successfully used the following code to access a 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;      <--- error  
}

现在,使用 Nativescript 6.4(并且在使用tns migrate"迁移我的应用程序之后)我在tns build android"上遇到编译器错误:

Now,with Nativescript 6.4 (and after migrating my app with "tns migrate") I am getting a compiler error on "tns build android":

TS2352:将View"类型转换为RadSideDrawer"类型可能是错误的,因为两种类型与另一种类型都没有足够的重叠.如果这是故意的,请先将表达式转换为未知".

TS2352: Conversion of type 'View' to type 'RadSideDrawer' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

我不知道如何解决这个问题.谁能告诉我我需要改变什么?那会超级好.谢谢!

I have no idea how to fix this. Could anybody tell me what i need to change? That would be super nice. Thank you!

推荐答案

我无法重现该问题,可能与您的 TS 版本或配置有关.

I'm unable to reproduce the issue on my end, it may be something to do with your TS version or configurations.

一个简单的解决方法是将对象转换为未知类型,正如错误描述所暗示的那样.

An easy fix is to cast the object to unknown type as the error description suggests.

let sideDrawer = <RadSideDrawer>(<any>args.object);

这篇关于如何从页面访问 RadSideDrawer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆