nonsense Usually, the browser title is set like this But Vue is a single-page application, and the entry file only has one HTML, so only one tag can be set. So here are two commonly used methods to dynamically set browser tags. textThe first Use the browser native method router/index.js //For multi-language projects, import i18n from '@/i18n/index' according to your own project; document.title = i18n.t("router." + to.name) //Single language project document.title = to.name The language switching route remains unchanged, so it should be added as well. Single language projects do not need it. //Multi-language project document.title = i18n.t("router." + to.name) Completed, recommended, native compatibility is good, no need to download and install other dependent packages The secondUsing plugins 1. Install the pluginnpm install vue-wechat-title --save 2.main.js referenceimport VueWechatTitle from 'vue-wechat-title'//Dynamically modify title Vue.use(VueWechatTitle) 3. Add instructions//Multi-language project <router-view v-wechat-title="$t('router.' + $route.name)" ></router-view> //Single language project <router-view v-wechat-title=" $route.name" ></router-view> Finished notes Note: The value depends on the routing structure of your own project. This demo uses the name value. i18n has a corresponding language package. You can add a title attribute in the meta object and use SummarizeThis article ends here. I hope it can be helpful to you. I also hope you can pay more attention to more content on 123WORDPRESS.COM! You may also be interested in:
|
<<: Introduction to the usage of exists and except in SQL Server
>>: The difference between float and position attributes in CSS layout
Table of contents 1. Introduction 2. Usage Statel...
Preface Because this is a distributed file system...
In this project, the Docker container is used to ...
css-vars-ponyfill When using CSS variables to ach...
Table of contents Methods of String Object Method...
1. What is a two-column layout? There are two typ...
This article mainly introduces the deployment of ...
Effect Fading from top to bottom Source code html...
The hyperlink <a> tag represents a link poin...
In the previous article https://www.jb51.net/arti...
There is no doubt that containers have become an ...
<!--[if IE 6]> Only IE6 can recognize <![...
The principle is to first write a div with a butt...
Execute the following command to report an error ...
This article mainly introduces the solution to th...