我正在使用vue-cli (3.4.1),尝试简单地更改文档的标题。
我在vue.config.js中添加了以下内容。
chainWebpack: (config) => {
config
.plugin('html')
.tap((args) => {
args[0].title = 'Custom Title';
return args;
});
},
并使用vue inspect --plugin html
检查了webpack配置,结果如下:
And inspected the webpack configuration with vue inspect --plugin html
, resulting in the following output:
/* config.plugin('html') */
new HtmlWebpackPlugin(
{
templateParameters: function () { /* omitted long function */ },
template: '<path>\node_modules\\@vue\\cli-service\\lib\\config\\index-default.html',
title: 'Custom Title'
}
)
Web应用程序的标题仍然显示为“Vue App”。
有任何想法为什么?
PS:我不希望在应用程序中的某个地方设置document.title ='Custom Title'
。 我希望在构建时更改文档的元素中