Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
102
rated 0 times [  107] [ 5]  / answers: 1 / hits: 18691  / 6 Years ago, tue, january 16, 2018, 12:00:00

I want to set the page title to a different value for each page.



In regular Vue.js, I have done the following:



import router from './router'
import { store } from './store/store';

router.beforeEach((to, from, next) => {
store.mutations.setRoute(to);
document.title = store.getters.pageTitle;
next();
}


How would I get that effect in nuxt?



That is, on both initial page load and when changing pages, I want the browser tab's title to change. For instance, from My App - About to My App - Profile.


More From » vue.js

 Answers
12

from nuxt docs, in each pages component you can define the head function that returns the title of page i.e.



head() {
return {
title: About page
};
}

[#55445] Friday, January 12, 2018, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
samara

Total Points: 326
Total Questions: 106
Total Answers: 103

Location: Cook Islands
Member since Thu, May 21, 2020
4 Years ago
;