[英]Angular - material component not working in IE11
I m using Angular 9 Material components to develop simple page with input,date picker and select box.我正在使用 Angular 9 Material 组件来开发带有输入、日期选择器和 select 框的简单页面。
It is working Chrome but not working IE11.它可以工作 Chrome 但不能工作 IE11。
Getting the following error in IE: SCRIPT1002: Syntax error vendor.js (6164,30)在 IE 中出现以下错误:SCRIPT1002: Syntax error vendor.js (6164,30)
Script in Vendor.js--> Vendor.js 中的脚本-->
/**
* Adds the given ID to the specified ARIA attribute on an element.
* Used for attributes such as aria-labelledby, aria-owns, etc.
*/
function addAriaReferencedId(el, attr, id) {
const ids = getAriaReferenceIds(el, attr);
if (ids.some(existingId => existingId.trim() == id.trim())) {
return;
}
ids.push(id.trim());
el.setAttribute(attr, ids.join(ID_DELIMITER));
}
Any help!!任何帮助! Thanks in advance!提前致谢!
Update the file .browserslistrc
.更新文件.browserslistrc
。 Change the line:换行:
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
to至
IE 11
Update the file polyfills.ts
.更新文件polyfills.ts
。 Uncomment these 2 lines取消注释这 2 行
import 'classlist.js'; // Run `npm install --save classlist.js`.
import 'core-js/es6/reflect';
Run this command to add the npm package.运行此命令以添加 npm package。
npm install --save classlist.js
Thanks for the quick response!
steps i did,
1. updated the browsers list to "IE9-11"
2. Update the file polyfills.ts. Uncomment these 2 lines
import 'classlist.js'; // Run `npm install --save classlist.js`.
//import 'core-js/es6/reflect'; // es6 is not found , so commented the line
Run this command to add the npm package.
npm install --save classlist.js
3. app.component.html-->
<mat-toolbar color="primary" class="fixed-header">
<mat-toolbar-row>
<a routerLink="/home">My Logo</a>
</mat-toolbar-row>
</mat-toolbar>
included all required material imports in one material.module.ts and imported in app.module.ts
import { MyMaterialModule } from './material.module';
material.module.ts -->
import { NgModule } from '@angular/core';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatDialogModule} from "@angular/material/dialog";
import {MatDatepickerModule} from '@angular/material/datepicker';
import {MatRadioModule} from '@angular/material/radio';
import {MatSelectModule} from '@angular/material/select';
import {MatSliderModule} from '@angular/material/slider';
import {MatDividerModule} from '@angular/material/divider';
import {MatToolbarModule} from '@angular/material/toolbar';
import {MatCardModule} from '@angular/material/card';
import {MatInputModule} from '@angular/material/input';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { MatNativeDateModule } from '@angular/material/core';
@NgModule({
imports: [MatFormFieldModule,MatDividerModule,MatSliderModule,MatSelectModule,MatRadioModule,MatDatepickerModule,MatDialogModule,
MatToolbarModule,MatCardModule,
MatInputModule,MatButtonModule,
MatIconModule,MatNativeDateModule
],
exports: [MatFormFieldModule,MatDividerModule,MatSliderModule,MatSelectModule,MatRadioModule,MatDatepickerModule,MatDialogModule,
MatToolbarModule,MatCardModule,
MatInputModule,MatButtonModule,
MatIconModule,MatNativeDateModule
],
})
export class MyMaterialModule { }
-----------------------
This simple header also not loading IE , Chrome working.
Note : plain Html tags data is loading IE not issues with plain html code.`enter code here`
Facing issue with material components
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.