一、注册全局指令

1.注册一个全局指令

Vue.directive('title', {
  inserted: function (el, binding) {
    document.title = el.innerText
    el.remove()
  }
})

2.在需要更改页面标题的组件内调用我们刚注册的指令

<div v-title>标题内容</div>

二、直接使用document.title

      

参考:https://segmentfault.com/a/1190000007387556

相关文章:

  • 2022-12-23
  • 2023-03-16
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
猜你喜欢
  • 2021-10-02
  • 2022-03-08
  • 2021-11-12
  • 2022-12-23
  • 2021-05-18
相关资源
相似解决方案