我使用的是vue cli(3.4.1),我试图简单地更改文档的标题.
我在vue中添加了以下内容.配置.js
chainWebpack: (config) => {
config
.plugin('html')
.tap((args) => {
args[0].title = 'Custom Title';
return args;
});
},
并用vue inspect --plugin html
判断了webpack配置,得到以下输出
/* 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'
}
)
该Webapp的标题仍然是"Vue App".
知道为什么吗?
PS:我不想在我的应用程序中设置document.title = 'Custom Title'
.我想在构建时修改文档<head>
元素中<title>
个标记之间的标题.