Home >Web Front-end >Vue.js >How to add a title in vue
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.
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 } })# in the main.js file ##Step 2: Add
<template> <div class="main" v-title data-title="登录"> </div> </template>to any location in the component. DoneRelated 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!