首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在index.html中隐式导入metat utf-8?

如何在index.html中隐式导入metat utf-8?
EN

Stack Overflow用户
提问于 2020-04-13 18:06:13
回答 1查看 17关注 0票数 0

我被要求隐式导入metat utf-8。

这是我的index.html

代码语言:javascript
复制
<!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>
EN

回答 1

Stack Overflow用户

发布于 2020-04-13 18:22:04

从'@angular/platform-browser‘在导入元中创建服务

从‘@angular/core’导入{ Injectable };从‘@angular/platform-browser’导入{ Meta };

代码语言:javascript
复制
@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获取参考

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61185526

复制
相关文章

相似问题

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