thanksd让我找到了正确的答案.因为Vue CLI已经有了html-webpack-plugin,所以我采用了Vue CLI的官方方式(https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-plugin).
1-增加public/index.html
<!DOCTYPE html>
<html>
<head>
<title><%= htmlWebpackPlugin.options.title %></title>
<meta charset="utf-8"/>
</head>
<body>
<div id="app"></div>
</body>
</html>
2-将元标记设置为vue.config.js
chainWebpack: (config) => {
config
.plugin('html')
.tap(args => {
args[0].title = 'MyApp title';
args[0].meta = {viewport: 'width=device-width,initial-scale=1,user-scalable=no'};
return args;
})
}