Angular 5 - 元描述不起作用 [英] Angular 5 - Meta description not working

查看:34
本文介绍了Angular 5 - 元描述不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Angular 的 Meta 函数有问题.

I got a problem with the Meta function of Angular.

从'@angular/platform-b​​rowser'导入{Meta};

import {Meta} from '@angular/platform-browser';

我已将其添加到我的页面contact.component.ts"上,但在我的网页上没有看到任何内容.没有元描述或其他内容.

I have added it on my page "contact.component.ts" but I'm not seeing anything on my web page. There is no meta description or something else.

这是我的页面代码:

import {Meta} from '@angular/platform-browser';


@Component({
  selector: 'app-contact',
  templateUrl: './contact.component.html',
  providers: [],
  styleUrls: ['contact.component.css']
})

export class ContactComponent implements OnInit {

  constructor(public meta: Meta, public http: Http, public router: Router, public RequestService: RequestService, public global: GlobalService) {
    this.meta.addTag({ name: 'description', content: 'This is metadata' });
  }

  ngOnInit() {
    this.global.redirectionIfNoConnecte();
    this.global.getJsonLanguage();
  }

}

你能救救我吗?:(

推荐答案

参考 this, HTML 元标记提供有关 HTML 文档的元数据.元数据不会显示在页面上,但可以机器解析.元元素通常用于指定页面描述、关键字、作者、最后修改时间和其他元数据.元数据可供浏览器(如何显示内容或重新加载页面)、搜索引擎(关键字)或其他 Web 服务使用.元标签在 SEO 中扮演着重要的角色.这是另一个关于如何使用元标记的有用链接.

Refer to this, The HTML meta tag provides metadata about the HTML document. Metadata aren’t displayed on the page but are machine parsable. Meta elements are typically used to specify the page description, keywords, author, last modified, and other metadata. The metadata can be used by browsers (how to display content or reload the page), search engines (keywords), or other web services. Meta tags play an important role in SEO. This is an another helpful link on how the meta tags are used.

这篇关于Angular 5 - 元描述不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆