1.修改网页标题、配置全局路径、跨域
在项目根目录下创建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
pathRewrite: {
// 重写路径请求
"^/api": "", //路径重写
},
},
// ....
},
},
};
2. 设置图标
在根目录下创建文件夹 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>
注意
:修改配置文件需要重新启动项目!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之家整理,本文链接:https://www.bmabk.com/index.php/post/48849.html