我被要求隐式导入metat utf-8。
这是我的index.html
<!DOCTYPE html>
<html lang="fr">
<head>
<base href="/">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<link rel="shortcut icon" href="assets/img/favicon.png" type="image/png">
<title>Projet</title>
<link rel="shortcut icon" type="image/png">
<link type="text/html" href="/node_modules/primeicons/primeicons.css"/>
</head>
<body ><app-root></app-root>
</body></html>发布于 2020-04-13 18:22:04
从'@angular/platform-browser‘在导入元中创建服务
从‘@angular/core’导入{ Injectable };从‘@angular/platform-browser’导入{ Meta };
@Injectable({providedIn: 'root'})
export class SEOService {
constructor(private meta: Meta) {
meta.addTags([
{name: 'description', content: 'Title and Meta tags examples'},
{name: 'viewport', content: 'width=device-width, initial-scale=1'},
{name: 'robots', content: 'INDEX, FOLLOW'},
{name: 'author', content: 'ABCD'},
{name: 'keywords', content: 'TypeScript, Angular'},
{name: 'date', content: '2018-06-02', scheme: 'YYYY-MM-DD'},
{httpEquiv: 'Content-Type', content: 'text/html'},
{property: 'og:title', content: "My Text"},
{property: 'og:type', content: "website"},
{charset: 'UTF-8'}
]);
}
}您还可以从Angular meta service获取参考
https://stackoverflow.com/questions/61185526
复制相似问题