美文网首页
vue设置TDK

vue设置TDK

作者: lesdom | 来源:发表于2020-11-13 12:23 被阅读0次

代码

utils/brower.js

export function changeTitle (title) {
  let dom = document.querySelector('title')
  if (dom) {
    dom.innerText = title
  }
}
export function changeKeywords (title) {
  let dom = document.querySelectorAll('meta')[3]
  if (dom) {
    dom.setAttribute("content",title)
  }
}
export function changeDescription (title) {
  let dom = document.querySelectorAll('meta')[4]
  if (dom) {
    dom.setAttribute("content",title)
  }
}

使用

import { changeKeywords ,changeDescription,changeTitle } from '@/utils/brower'

  beforeCreate () {
    changeTitle('Title')
    changeKeywords('Keywords')
    changeDescription('Description')
  },

相关文章

网友评论

      本文标题:vue设置TDK

      本文链接:https://www.haomeiwen.com/subject/xcpvbktx.html