首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我得到的错误类型‘未定义’是不能指定键入.?

为什么我得到的错误类型‘未定义’是不能指定键入.?
EN

Stack Overflow用户
提问于 2022-10-15 12:40:00
回答 1查看 43关注 0票数 0

我创造了一个新的角度应用程序。

在我的app.component.html里

代码语言:javascript
复制
<bryntum-scheduler
    #scheduler
    [resources] = "resources"
    [events] = "events"
    [columns] = "schedulerConfig.columns"
    [startDate] = "schedulerConfig.startDate!"
    [endDate] = "schedulerConfig.endDate!"
></bryntum-scheduler>

app.component.ts看起来就像

代码语言:javascript
复制
import { Component, ViewChild } from '@angular/core';
import { BryntumSchedulerComponent } from '@bryntum/scheduler-angular';
import { schedulerConfig } from './app.config';

@Component({
    selector    : 'app-root',
    templateUrl : './app.component.html',
    styleUrls   : ['./app.component.scss']
})
export class AppComponent {
    resources = [
        { id : 1, name : 'Dan Stevenson' },
        { id : 2, name : 'Talisha Babin' }
    ];

    events = [
        { resourceId : 1, startDate : '2022-01-01', endDate : '2022-01-10' },
        { resourceId : 2, startDate : '2022-01-02', endDate : '2022-01-09' }
    ];

    schedulerConfig = schedulerConfig;

    @ViewChild('scheduler') schedulerComponent!: BryntumSchedulerComponent;
}

这是app.config.ts (与app.component.ts位于同一个文件夹中):

代码语言:javascript
复制
import { SchedulerConfig } from '@bryntum/scheduler';

export const schedulerConfig: Partial<SchedulerConfig> = {
    columns : [
        { text : 'Name', field : 'name', width : 160 }
    ],
    startDate : new Date(2022, 10, 17),
    endDate   : new Date(2022, 10, 23)
};

当我试图编译我的应用程序时,我会得到错误。

类型'undefined‘不能分配到键入'object而论( object[] )、[ ColumnStore ]、[部分]、[部分]、[[部分]]、[[Partial[]。 5列= "schedulerConfig.columns“

我没有看到这个错误的原因。有人能帮我吗?

EN

回答 1

Stack Overflow用户

发布于 2022-10-15 14:54:07

基于正式的文档ColumnStore具有许多属性,其中一些属性是您定义的(文本、字段、宽度),因此在传递到此组件时,您可以将columns“软”转换为ColumnStore

代码语言:javascript
复制
<bryntum-scheduler
    #scheduler
    [resources] = "resources"
    [events] = "events"
    [columns] = "schedulerConfig.columns as ColumnStore" <!--here-->
    [startDate] = "schedulerConfig.startDate!"
    [endDate] = "schedulerConfig.endDate!"
></bryntum-scheduler>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74079518

复制
相关文章

相似问题

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