Home > Web Front-end > Vue.js > How to add a title in vue

How to add a title in vue

青灯夜游
Release: 2021-10-27 12:04:40
Original
4907 people have browsed it

How to add a title in vue: 1. Add the "document.title = el.dataset.title" statement in the "main.js" file; 2. Set "v-title data" in the label of the required component -title="Login"" attribute is enough.

How to add a title in vue

The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.

vue project adds the title that changes the browser tag title

Step one: add

// 设置浏览器标题
Vue.directive('title', {
  inserted: function (el, binding) {
    document.title = el.dataset.title
  }
})
Copy after login
# in the main.js file ##Step 2: Add

<template>
    <div class="main" v-title data-title="登录">
    </div>
</template>
Copy after login
to any location in the component. Done

Related recommendations: "

vue.js Tutorial"

The above is the detailed content of How to add a title in vue. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template