首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >应为2个参数,但获得了1.ts(2554) core.d.ts(8054,47):未提供'opts‘的参数

应为2个参数,但获得了1.ts(2554) core.d.ts(8054,47):未提供'opts‘的参数
EN

Stack Overflow用户
提问于 2019-06-12 23:51:04
回答 2查看 2.1K关注 0票数 1

这是我的代码的一部分,我得到了这个错误:

代码语言:javascript
复制
Expected 2 arguments, but got 1.ts(2554)
core.d.ts(8054, 47): An argument for 'opts' was not provided.

从这里开始:

代码语言:javascript
复制
import {ViewChild, ChangeDetectorRef, AfterViewInit} from "@angular/core"; 
import {RadSideDrawerComponent, SideDrawerType} from "nativescript-telerik-ui/sidedrawer/angular";

export class DrawerPage implements AfterViewInit {
    @ViewChild(RadSideDrawerComponent) protected drawerComponent: RadSideDrawerComponent; 
    protected drawer: SideDrawerType;

    constructor(private _changeDetectorRef: ChangeDetectorRef) { }

    ngAfterViewInit() { 
        this.drawer = this.drawerComponent.sideDrawer; 
        this._changeDetectorRef.detectChanges(); 
    }

    protected openDrawer() { 
        this.drawer.showDrawer(); 
    }

    protected closeDrawer() { 
        this.drawer.closeDrawer(); 
    }
}

我不明白问题出在哪里?我是一个新的学习者谁遵循教程视频学习NativeScript!

EN

回答 2

Stack Overflow用户

发布于 2020-03-31 22:02:34

在Angular 8中,ViewChild有两个参数:

试着这样做:

代码语言:javascript
复制
@ViewChild('nameInput', { static: false }) nameInputRef: ElementRef;

解释:

静态{:false }

如果设置为static false,则组件始终在视图初始化后被初始化,以供ngAfterViewInit/ngAfterContentInit回调函数使用。

静态{:true}

如果将static设置为true,则初始化将在ngOnInit的视图初始化时进行

默认情况下可以使用{ static: false }。如果要创建动态视图并希望使用模板引用变量,则应使用{ static: true}

有关更多信息,请阅读此here

谢谢。

票数 2
EN

Stack Overflow用户

发布于 2019-06-13 09:18:31

您正在使用nativescript-telerik-ui/sidedrawer,但最新版本的Nativscript.This包已被deprecated支持。

对于侧面抽屉,请使用nativescript-ui-sidedrawer

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56566109

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档