gpt4 book ai didi

angular - “全日历”不是已知元素 :

转载 作者:行者123 更新时间:2023-12-05 05:04:22 39 4
gpt4 key购买 nike

嘿,我是 Angular 的新手...到目前为止,我想试用完整日历。我之前尝试运行该模块并且它有效。然而,今天我创建了一个新项目,并按照 Angular 文档中描述的步骤进行操作此外,我完成了完整日历文档中的所有步骤,但它仍然无法正常工作。

这是我遇到的错误:

ERROR in src/app/app.component.html:1:1 - error NG8001: 'full-calendar' is not a known element:
1. If 'full-calendar' is an Angular component, then verify that it is part of this module.
2. If 'full-calendar' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

1 <full-calendar defaultView="dayGridMonth" [plugins]="calendarPlugins"></full-calendar>

应用程序模块.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {FullCalendarModule} from '@fullcalendar/angular';
import { AppComponent } from './app.component';

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FullCalendarModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

应用程序组件.ts

import { Component } from '@angular/core';
import dayGridPlugin from '@fullcalendar/daygrid';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'nachweis-frontend';
calendarPlugins = [dayGridPlugin];
}

app.component.html

<full-calendar [plugins] = "calendarPlugins"></full-calendar>

这也是我的 Angular json。我在这里没有做任何更改:

{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"nachweis-frontend": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/nachweis-frontend",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "nachweis-frontend:build"
},
"configurations": {
"production": {
"browserTarget": "nachweis-frontend:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "nachweis-frontend:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "nachweis-frontend:serve"
},
"configurations": {
"production": {
"devServerTarget": "nachweis-frontend:serve:production"
}
}
}
}
}
},
"defaultProject": "nachweis-frontend",
"cli": {
"analytics": false
}
}

最佳答案

查看您的 GitHub 代码后,我知道它在您发布的文件中,但出于某种原因,它在您的 GitHub 中的 app.module.ts 中丢失了:

从“@fullcalendar/angular”导入 { FullCalendarModule};

imports: [
BrowserModule,
FullCalendarModule
],

我在我的机器上测试了它,所以只要你安装了 package.json 中的所有 npm 包,你的代码现在应该可以工作了

关于angular - “全日历”不是已知元素 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61121154/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com