
在项目根目录下创建vue的配置文件 vue.config.js,在该文件中设置网站的标题
const path = require("path");
module.exports = {
// 网页标题
chainWebpack: (config) => {
config.plugin("html").tap((args) => {
args[0].title = "网站标题";
return args;
});
},
// 全局路径
configureWebpack: {
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
"~mock": path.resolve(__dirname, "mock"),
},
},
},
// 跨域
devServer: {
proxy: {
"/api": {
target: "接口地址https://",
changeOrigin: true, // 是否允许跨域
secure: false, // 关闭SSL证书验证https协议接口需要改成true
logLevel: "debug",//控制台打印代理后的url
pathRewrite: {
// 重写路径请求
"^/api": "", //路径重写
},
},
// ....
},
},
};在根目录下创建文件夹 public ,在该目录下创建如下的文件
其中,名为 favicon.ico 是要设置的图标图标,但是图片的全名必须设置为 favicon.ico 。
文件 index.html 不可缺少,其内容如下:
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>注意:修改配置文件需要重新启动项目!
下班~