I have a solution and I used it on one of the projects .
First create a directive.
Vue.directive('title', { inserted: (el, binding) => document.title = binding.value, update: (el, binding) => document.title = binding.value })
Suppose we are working on a file 'MyComponent.vue' .
Then use this directive for the router-view component.
<router-view v-title="title" ></router-view> export default { data(){ return { title: 'This will be the title' } } }
This works even if the component is updated or the page is reloaded.
Worked very well for me!
Shaikh takkar
source share