填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

Meta

A service for managing HTML <meta> tags.

查看"说明"...

      
      class Meta {
  addTag(tag: MetaDefinition, forceCreation: boolean = false): HTMLMetaElement | null
  addTags(tags: MetaDefinition[], forceCreation: boolean = false): HTMLMetaElement[]
  getTag(attrSelector: string): HTMLMetaElement | null
  getTags(attrSelector: string): HTMLMetaElement[]
  updateTag(tag: MetaDefinition, selector?: string): HTMLMetaElement | null
  removeTag(attrSelector: string): void
  removeTagElement(meta: HTMLMetaElement): void
}
    

参见

说明

Properties of the MetaDefinition object match the attributes of the HTML <meta> tag. These tags define document metadata that is important for things like configuring a Content Security Policy, defining browser compatibility and security settings, setting HTTP Headers, defining rich content for social sharing, and Search Engine Optimization (SEO).

To identify specific <meta> tags in a document, use an attribute selection string in the format "tag_attribute='value string'". For example, an attrSelector value of "name='description'" matches a tag whose name attribute has the value "description". Selectors are used with the querySelector() Document method, in the format meta[{attrSelector}].

方法

Retrieves or creates a specific <meta> tag element in the current HTML document. In searching for an existing tag, Angular attempts to match the name or property attribute values in the provided tag definition, and verifies that all other attribute values are equal. If an existing element is found, it is returned and is not modified in any way.

addTag(tag: MetaDefinition, forceCreation: boolean = false): HTMLMetaElement | null
      
      addTag(tag: MetaDefinition, forceCreation: boolean = false): HTMLMetaElement | null
    
参数
tag MetaDefinition

The definition of a <meta> element to match or create.

forceCreation boolean

可选. 默认值是 false.

True to create a new element without checking whether one already exists.

返回值

HTMLMetaElement | null: The existing element with the same attributes and values if found, the new element if no match is found, or null if the tag parameter is not defined.

Retrieves or creates a set of <meta> tag elements in the current HTML document. In searching for an existing tag, Angular attempts to match the name or property attribute values in the provided tag definition, and verifies that all other attribute values are equal.

addTags(tags: MetaDefinition[], forceCreation: boolean = false): HTMLMetaElement[]
      
      addTags(tags: MetaDefinition[], forceCreation: boolean = false): HTMLMetaElement[]
    
参数
tags MetaDefinition[]

An array of tag definitions to match or create.

forceCreation boolean

可选. 默认值是 false.

True to create new elements without checking whether they already exist.

返回值

HTMLMetaElement[]: The matching elements if found, or the new elements.

Retrieves a <meta> tag element in the current HTML document.

getTag(attrSelector: string): HTMLMetaElement | null
      
      getTag(attrSelector: string): HTMLMetaElement | null
    
参数
attrSelector string

The tag attribute and value to match against, in the format "tag_attribute='value string'".

返回值

HTMLMetaElement | null: The matching element, if any.

Retrieves a set of <meta> tag elements in the current HTML document.

getTags(attrSelector: string): HTMLMetaElement[]
      
      getTags(attrSelector: string): HTMLMetaElement[]
    
参数
attrSelector string

The tag attribute and value to match against, in the format "tag_attribute='value string'".

返回值

HTMLMetaElement[]: The matching elements, if any.

Modifies an existing <meta> tag element in the current HTML document.

updateTag(tag: MetaDefinition, selector?: string): HTMLMetaElement | null
      
      updateTag(tag: MetaDefinition, selector?: string): HTMLMetaElement | null
    
参数
tag MetaDefinition

The tag description with which to replace the existing tag content.

selector string

可选. 默认值是 undefined.

A tag attribute and value to match against, to identify an existing tag. A string in the format "tag_attribute=value string". If not supplied, matches a tag with the same name or property attribute value as the replacement tag.

返回值

HTMLMetaElement | null: The modified element.

Removes an existing <meta> tag element from the current HTML document.

removeTag(attrSelector: string): void
      
      removeTag(attrSelector: string): void
    
参数
attrSelector string

A tag attribute and value to match against, to identify an existing tag. A string in the format "tag_attribute=value string".

返回值

void

Removes an existing <meta> tag element from the current HTML document.

removeTagElement(meta: HTMLMetaElement): void
      
      removeTagElement(meta: HTMLMetaElement): void
    
参数
meta HTMLMetaElement

The tag definition to match against to identify an existing tag.

返回值

void