How to Set webpage title on vue2 single page and vue2 webpage title

Source: Internet
Author: User

How to Set webpage title on vue2 single page and vue2 webpage title

The content in the response, and the title of the page is set only once when each page is initialized. For the current front-end framework, the traditional method of setting the title label for each page is not good.

We recommend that you use the vue-wechat-title plug-in.

Download and install plug-in Dependencies

Npm install vue-wechat-title -- save

Introduce plug-ins in main. js

Import VueWechatTitle from 'vue-wechat-title' vue. use (VueWechatTitle)

Add a title to each route in the route file index. js.

Routes: [{path: '/', name: 'index', component: index, meta: {title: 'homepage' // set the title here },{ path: '/detail', name: 'detail', component: detail, meta: {title: 'details page' // set the title here}]

Modify the router-view component in app. vue.

<Router-view v-wechat-title = '$ route. meta. title'> </router-view>

Restart and try again.

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.