Currently, after generating a project with Vue CLI 3 the title is "Vue App".
If I set the title in the created hook via document.title the browser will still will flash "Vue App" prior to displaying the title set via document.title.
Looking for a way to set the HTML title for a Vue CLI 3 generated project without it flashing the default "Vue App" title first.
This can be simply done by changing the content of the <title> tag in our html code. But for Single-Page Applications, things are a little bit different. When the router changes to a different page component, the title should be changed programmatically using document. title = 'new title' .
The simplest way to get started with Vue is to grab the development version script for it and add it to the head tag of your HTML file. Then you can start Vue code inside the HTML file inside of script tags. And have the Vue code connect up with an existing element on your HTML page.
You can set the title in /public/index.html
statically.
Setting it to an empty string in index.html and keeping the update in the hook gets rid of the flashing.
also You can use custom index.html in another way, modify your vue.config.js:
module.exports = {
publicPath: '/',
chainWebpack: config => {
config
.plugin("html")
.tap(args => {
args[0].template = './public/index.html'
return args
})
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With