在本文中,我们将带你了解asp.net–元素’ToolkitScriptManager’不是已知元素在这篇文章中,我们将为您详细介绍asp.net–元素’ToolkitScriptManager’不是
在本文中,我们将带你了解asp.net – 元素’ToolkitScriptManager’不是已知元素在这篇文章中,我们将为您详细介绍asp.net – 元素’ToolkitScriptManager’不是已知元素的方方面面,并解答不是已知的css属性名常见的疑惑,同时我们还将给您一些技巧,以帮助您实现更有效的'mat-datepicker-actions' 不是已知元素 - 需要最佳解决方案、
- asp.net – 元素’ToolkitScriptManager’不是已知元素(不是已知的css属性名)
- 'mat-datepicker-actions' 不是已知元素 - 需要最佳解决方案
不是已知元素 - Angular 2“组件”不是已知元素
- Angular 5 Material 5 MatTableDataSource …“’mat-card-title’不是已知元素.”
asp.net – 元素’ToolkitScriptManager’不是已知元素(不是已知的css属性名)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebParts.aspx.cs" Inherits="e.WebParts" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager> <div> <asp:TabContainer ID="TabContainer1" runat="server"> <asp:TabPanel ID="TabPanel1" runat="server"> <ContentTemplate>Page One</ContentTemplate> </asp:TabPanel> <asp:TabPanel ID="TabPanel2" runat="server"> <ContentTemplate>Page Two</ContentTemplate> </asp:TabPanel> <asp:TabPanel ID="TabPanel3" runat="server"> <ContentTemplate>Page Three</ContentTemplate> </asp:TabPanel> </asp:TabContainer> </div> </form> </body> </html>
这样就可以在标签容器中创建3个标签面板.
但是,当我更改该页面以使用MasterPage.master看起来像这样 –
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebParts.aspx.cs" Inherits="eservice.WebParts" MasterPageFile="~/MasterPage.Master"%> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <asp:LoginView ID="LoginView1" runat="server"> <LoggedInTemplate> <p id="backtoblog"></p> <p> Preferences</p> <div> <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager> <div> <asp:TabContainer ID="TabContainer1" runat="server"> <asp:TabPanel ID="TabPanel1" runat="server"> <ContentTemplate>Page One</ContentTemplate> </asp:TabPanel> <asp:TabPanel ID="TabPanel2" runat="server"> <ContentTemplate>Page Two</ContentTemplate> </asp:TabPanel> <asp:TabPanel ID="TabPanel3" runat="server"> <ContentTemplate>Page Three</ContentTemplate> </asp:TabPanel> </asp:TabContainer> </div> </div> </LoggedInTemplate> <Anonymoustemplate> You are not logged in. <br /> Please login to access eservice </Anonymoustemplate> </asp:LoginView> </asp:Content>
VS2008给了我以下警告:
Element ‘ToolkitScriptManager’ is not
a kNown element. This can occur if
there is a compilation error in the
Web site,or the web.config file is
missing.
在以下行:
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
解决方法
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
你在第一个文件中有.仅仅因为母版页知道了asp:前缀以及与之关联的程序集/命名空间,并不意味着子页面会这样做.
更好的方法是在web.config中注册程序集/名称空间/标记前缀,如下所示:
<configuration> <!-- ... --> <system.web> <!-- ... --> <pages> <controls> <add tagPrefix="asp" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" /> </controls> </pages> </system.web> </configuration>
'mat-datepicker-actions' 不是已知元素 - 需要最佳解决方案
如何解决''mat-datepicker-actions'' 不是已知元素 - 需要最佳解决方案?
我导入了 MatDatepickerModule
并且获取 mat-datepicker-actions
未知。我想还有一些其他模块需要导入。这是代码片段:
<mat-form-field appearance="fill">
<mat-label>Choose a date</mat-label>
<input matInput [matDatepicker]="datepicker">
<mat-datepicker-toggle matSuffix [for]="datepicker"></mat-datepicker-toggle>
<mat-datepicker #datepicker>
<mat-datepicker-actions>
<button mat-button matDatepickerCancel>Cancel</button>
<button mat-raised-button color="primary" matDatepickerApply>Apply</button>
</mat-datepicker-actions>
</mat-datepicker>
</mat-form-field>
注意:任何人都在 angular-material
库中提供解决方案,而不是第三方(通常大小太大)。我会很感激的。
解决方法
确保导入 MatDatepickerModule
和 MatMomentDateModule
。
import { MatDatepickerModule,MatMomentDateModule } from ''@coachcare/datepicker'';
@NgModule({
imports: [
MatDatepickerModule,MatMomentDateModule,...
],...
})
export class AppModule {}
更新:
coachcare/npm-datepicker 是官方 Material 的 Fork 用于 Angular v6 的日期选择器,支持时间选择器。日期选择器 允许用户通过文本输入或选择来输入日期 日历中的日期。它由几个组件和 协同工作的指令。
angular 本身没有官方日期和时间选择器,这就是为什么人们基于官方解决方案创建解决方案,并在此基础上添加新功能。然而,这些 fork 并不总是与最新的 angular/angular-material 版本保持同步,因此依赖它们是不明智的。
您可以找到有关此 stackoverflow thread 的更多详细信息
,您需要将 MatDatepickerModule
和 MatNativeDateModule
导入到您的组件所属的模块中。我在下面使用 Angular 11
import { MatDatepickerModule } from ''@angular/material/datepicker'';
import { MatNativeDateModule } from ''@angular/material/core'';
@NgModule({
declarations: [
...
],imports: [
...
MatNativeDateModule,MatDatepickerModule
...
,
不需要第三方库,您可以通过更新 @angular/material
来修复它。
ng update @angular/material
感谢@msrumon,他找到了这个解决方案。
,mat-datepicker-actions
在 Angular Material Docs 的 11.2.13
版本中。
我的问题是我使用了 @angular/material: 11.0.0
。所以我更新了我的包:npm update @angular/material @angular/cdk
,现在一切正常。
不是已知元素
感谢@Yuriy 重点是添加
import { AddBottle } from './components/bottle-list/bottle-list.component'
到我的 app-module.ts
Angular 2“组件”不是已知元素
我正在尝试在其他模块中使用我在 AppModule 中创建的组件。我收到以下错误:
“未捕获(承诺):错误:模板解析错误:
‘contacts-box’ 不是已知元素:
- 如果 ‘contacts-box’ 是一个 Angular 组件,那么验证它是这个模块的一部分。
- 如果“contacts-box”是一个 Web
组件,则将“CUSTOM_ELEMENTS_SCHEMA”添加到该组件的“@NgModule.schemas”以禁止显示此消息。
我的项目结构很简单:
我将我的页面保存在 pages
目录中,每个页面保存在不同的模块中(例如客户模块),每个模块都有多个组件(如客户列表组件、客户添加组件等)。我想在这些组件中使用我的
ContactBoxComponent(例如在客户添加组件中)。
如您所见,我在小部件目录中创建了联系人框组件,因此它基本上位于 AppModule 中。我将 ContactBoxComponent 导入添加到
app.module.ts 并将其放入 AppModule 的声明列表中。它没有用,所以我搜索了我的问题并将 ContactBoxComponent
添加到导出列表中。没有帮助。我还尝试将 ContactBoxComponent 放入 CustomersAddComponent
中,然后放入另一个(来自不同的模块),但我收到一个错误,说有多个声明。
我错过了什么?
答案1
小编典典这些是我遇到此类错误时执行的 5 个步骤。
- 你确定名字是对的吗?(还要检查组件中定义的选择器)
- 在模块中声明组件?
- 如果它在另一个模块中,导出组件?
- 如果它在另一个模块中,导入那个模块?
- 重启cli?
在单元测试期间发生错误时,请确保您声明了组件或导入了模块TestBed.configureTestingModule
我还尝试将 ContactBoxComponent 放入 CustomersAddComponent
中,然后放入另一个(来自不同的模块),但我收到一个错误,说有多个声明。
您不能两次声明一个组件。您应该在一个新的单独模块中声明和导出您的组件。接下来,您应该在要使用组件的每个模块中导入这个新模块。
很难说什么时候应该创建新模块,什么时候不应该。我通常为我重用的每个组件创建一个新模块。当我有一些几乎在任何地方都使用的组件时,我将它们放在一个模块中。当我有一个不重复使用的组件时,我不会创建一个单独的模块,直到我在其他地方需要它。
尽管将所有组件放在一个模块中可能很诱人,但这对性能不利。在开发过程中,每次进行更改时,模块都必须重新编译。模块越大(组件越多),花费的时间就越多。对大模块进行小改动比在小模块中进行小改动需要更多时间。
Angular 5 Material 5 MatTableDataSource …“’mat-card-title’不是已知元素.”
TL; DR:将@ angular / core,@ angular / material和@ angular / CDK升级到版本5后,我突然无法使用与mat-card相关的标签.
我无法使所有依赖项都正确无法导入MatTableDataSource.我意识到我可以实现自己的DataSource like this,但是如果它在文档中,那么确实可以在没有这个黑客的情况下进行工作配置.实现我自己的DataSource也意味着丢失漂亮的可排序标头和过滤,这是我最常追求的.
我将项目升级到Angular 5思考材料也将升级,但事实并非如此.材料和CDK保持在“^ 2.0.0-beta.12”.
在npm安装后我看到了这些警告:
npm WARN @angular/cdk@5.0.4 requires a peer of @angular/core@~5.1.1 but none is installed. You must install peer dependencies yourself. npm WARN @angular/cdk@5.0.4 requires a peer of @angular/common@~5.1.1 but none is installed. You must install peer dependencies yourself. npm WARN @angular/material@5.0.4 requires a peer of @angular/core@~5.1.1 but none is installed. You must install peer dependencies yourself. npm WARN @angular/material@5.0.4 requires a peer of @angular/common@~5.1.1 but none is installed. You must install peer dependencies yourself. npm WARN @ng-bootstrap/ng-bootstrap@1.0.0-beta.6 requires a peer of @angular/core@^4.0.3 but none is installed. You must install peer dependencies yourself. npm WARN @ng-bootstrap/ng-bootstrap@1.0.0-beta.6 requires a peer of @angular/common@^4.0.3 but none is installed. You must install peer dependencies yourself. npm WARN @ng-bootstrap/ng-bootstrap@1.0.0-beta.6 requires a peer of @angular/forms@^4.0.3 but none is installed. You must install peer dependencies yourself. npm WARN angular2-flash-messages@1.0.8 requires a peer of @angular/core@^4.0.0 but none is installed. You must install peer dependencies yourself. npm WARN angular2-jwt@0.2.3 requires a peer of @angular/core@^2.0.0||^4.0.0 but none is installed. You must install peer dependencies yourself. npm WARN angular2-jwt@0.2.3 requires a peer of @angular/http@^2.0.0||^4.0.0 but none is installed. You must install peer dependencies yourself. npm WARN codelyzer@3.0.1 requires a peer of @angular/compiler@^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself. npm WARN codelyzer@3.0.1 requires a peer of @angular/core@^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
…但是ng build成功了,我的应用程序的其余部分在package.json中运行正常:
dependencies": { "@angular/animations": "^5.2.0","@angular/cdk": "^2.0.0-beta.12","@angular/common": "^5.2.0","@angular/compiler": "^5.2.0","@angular/core": "^5.2.0","@angular/forms": "^5.2.0","@angular/http": "^5.2.0","@angular/material": "^2.0.0-beta.12","@angular/platform-browser": "^5.2.0","@angular/platform-browser-dynamic": "^5.2.0","@angular/platform-server": "^5.2.0","@angular/router": "^5.2.0","@ng-bootstrap/ng-bootstrap": "1.0.0-beta.6","angular-material-prefix-updater": "0.0.6","angular2-flash-messages": "^1.0.8","angular2-jwt": "^0.2.3","core-js": "^2.5.3","moment": "^2.20.1","ng2-file-upload": "^1.3.0","ngx-pagination": "^3.0.3","quill": "^1.3.4","rxjs": "^5.5.6","zone.js": "^0.8.19" },"devDependencies": { "@angular/cli": "^1.6.3","@angular/compiler-cli": "^5.2.0","@angular/language-service": "^4.4.6","@types/jasmine": "^2.8.3","@types/jasminewd2": "^2.0.3","@types/node": "^6.0.96","codelyzer": "~3.0.1","jasmine-core": "~2.6.2","jasmine-spec-reporter": "~4.1.0","karma": "^1.7.1","karma-chrome-launcher": "~2.1.1","karma-cli": "~1.0.1","karma-coverage-istanbul-reporter": "^1.3.3","karma-jasmine": "^1.1.1","karma-jasmine-html-reporter": "^0.2.2","protractor": "~5.1.2","ts-node": "~3.0.4","tslint": "~5.3.2","typescript": "2.4.2","webpack": "^3.10.0" }
此时,我仍然无法导入MatTableDataSource:
...node_modules/@angular/material/material"' has no exported member 'MatTableDataSource'.
…所以我增加了Material和CDK版本:
git diff package.json:
"dependencies": { "@angular/animations": "^5.2.0",- "@angular/cdk": "^2.0.0-beta.12",+ "@angular/cdk": "^5.0.0-rc0",- "@angular/material": "^2.0.0-beta.12",+ "@angular/material": "^5.0.0-rc0",. .
现在我可以毫无问题地构建,但是当我的页面呈现时,我在控制台中看到了这一点:
Uncaught Error: Template parse errors: 'mat-card-title' is not a kNown element: 1. If 'mat-card-title' is an Angular component,then verify that it is part of this module. 2. If 'mat-card-title' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
……现在我完全糊涂了.我在模板中使用的每个“未知”材料卡相关标签都存在上述错误之一.突然没有材料卡可供使用,我做错了什么?
解决方法
这么明显的答案! …但是,我必须检查更改日志和文档,以便找到之前,当我使用较低版本的CDK和Material时不需要导入的原因.跳转到(更高)更高版本后,模板解析错误才会出现.
关于asp.net – 元素’ToolkitScriptManager’不是已知元素和不是已知的css属性名的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于'mat-datepicker-actions' 不是已知元素 - 需要最佳解决方案、
本文标签: