当前位置: 首页 > news >正文

深圳的网站建设公司价格建设创意网站

深圳的网站建设公司价格,建设创意网站,天津百度seo排名优化,给个免费网站好人有好报第一步:在src同级新建 .env.production 、.env.test 、.env.development文件 第二步:在文件中配置开发环境、生产环境、测试环境 // 开发环境 .env.developmentNODE_ENV developmentVUE_APP_MODE development outputDir dist_dev // 打出包的名称VUE_…

第一步:在src同级新建 .env.production 、.env.test 、.env.development文件
第二步:在文件中配置开发环境、生产环境、测试环境

		// 开发环境 .env.developmentNODE_ENV = 'development'VUE_APP_MODE = 'development' outputDir = dist_dev // 打出包的名称VUE_APP_BASE_URL = http://xxxxxxxxx:xxxx/// 生产环境 .env.productionNODE_ENV = 'production'VUE_APP_MODE = 'production'outputDir = dist_proVUE_APP_BASE_URL = http://xxxxxxxxx:xxxx/// 测试环境 .env.testNODE_ENV = 'alpha' // 此处不能为test,否则会报错VUE_APP_MODE = 'alpha'// 此处不能为test,否则会报错outputDir = dist_testVUE_APP_BASE_URL = http://xxxxxxxxxxxx:xxxx/

第三步:在axios.js中配置基础

import axios from "axios";
import { ElMessage, ElMessageBox } from 'element-plus'
import router from '../router/index';
//axios请求配置
const config = {// 访问后端baseURL: process.env.VUE_APP_BASE_URL,//超时时间timeout: 1000000
}
//class:定义一个类
class Server {//构造函数里面初始化constructor(config) {this.instance = axios.create(config)//定义拦截器:请求发送之前和请求返回之后处理this.interceptors()}//拦截器interceptors() {//axios发送请求之前的处理this.instance.interceptors.request.use((config) => {//token携带let token = localStorage.getItem('token');if (token != null) {config.headers.token = token}let tokenUser = localStorage.getItem('tokenUser');if (tokenUser != null) {config.headers.tokenUser = tokenUser}return config;}, (error) => {error.data = {}error.data.msg = '服务器异常,请联系管理员!'return error;})//axios请求返回之后的处理//请求返回之后的处理this.instance.interceptors.response.use((res) => {if (res.data.code == 0 && res.data.msg?.includes('请先注册')) {return res.data;}if (res.data.code == 0) {if (res.data.msg != 'wxnull') {ElMessage({ type: 'error', message: res.data.msg })}return res.data} else {return res.data}}, (error) => {error.data = {};if (error && error.response) {switch (error.response.status) {case 400:error.data.msg = '错误请求';return ElMessage({ type: 'error', message: error.data.msg })case 401:error.data.msg = '未授权,请重新登录';return ElMessage({ type: 'error', message: error.data.msg })case 403:error.data.msg = '拒绝访问';return ElMessageBox.confirm('很抱歉,登录已过期,请重新登录', '登录已过期', {confirmButtonText: '重新登录',type: 'error',showCancelButton: false}).then(() => {router.push('/login');localStorage.removeItem('token');})case 404:error.data.msg = '请求错误,未找到该资源';return ElMessage({ type: 'error', message: error.data.msg })case 405:error.data.msg = '请求方法未允许';return ElMessage({ type: 'error', message: error.data.msg })case 408:error.data.msg = '请求超时';return ElMessage({ type: 'error', message: error.data.msg })case 500:error.data.msg = '服务器端出错';return ElMessage({ type: 'error', message: error.data.msg })case 501:error.data.msg = '网络未实现';return ElMessage({ type: 'error', message: error.data.msg })case 502:error.data.msg = '网络错误';return ElMessage({ type: 'error', message: error.data.msg })case 503:error.data.msg = '服务不可用';return ElMessage({ type: 'error', message: error.data.msg })case 504:error.data.msg = '网络超时';return ElMessage({ type: 'error', message: error.data.msg })case 505:error.data.msg = 'http版本不支持该请求';return ElMessage({ type: 'error', message: error.data.msg })default:error.data.msg = `连接错误${error.response.status}`;return ElMessage({ type: 'error', message: error.data.msg })}} else {error.data.msg = "连接到服务器失败";// router.push('/login');return ElMessage({ type: 'error', message: error.data.msg })}return Promise.reject(error)})}/* GET 方法 */get(url, params) {return this.instance.get(url, { params })}/* POST 方法 */post(url, data) {return this.instance.post(url, data)}/* PUT 方法 */put(url, data) {return this.instance.put(url, data)}/* DELETE 方法 */delete(url) {return this.instance.delete(url)}//图片上传upload(url, params) {return this.instance.post(url, params, {headers: {'Content-Type': 'multipart/form-data'}})}upimg(url, params) {return this.instance.get(url, params, {headers: {'Content-Type': 'application/octet-stream'}})}
}
export default new Server(config)

第四步:在package.json中配置基础

"scripts": {"serve": "vue-cli-service serve","build": "vue-cli-service build","lint": "vue-cli-service lint","serve:development": "vue-cli-service serve --mode development","build:development": "vue-cli-service build --mode development","serve:production": "vue-cli-service serve --mode production","build:production": "vue-cli-service build --mode production"}
// 使用yarn/npm run serve:development/production 运行
// 使用yarn/npm run build:development/production 打包

第五步:在babel.config.js中配置基础

 compact: false, // 加上此项配置env: {development: {plugins: ['dynamic-import-node']}}
http://www.yayakq.cn/news/892087/

相关文章:

  • 临沂网站制作哪家好如何常看wordpress默认编辑器
  • dede网站模板怎么安装教程品牌建设经验交流材料
  • 友汇网 做公司网站做文案应该关注的网站推荐
  • 网站收录后然后怎么做网站建设目前流行什么
  • 做网站的一般多钱多种郑州网站建设
  • 即墨网站建设网站推广公司官网
  • 国内做外单的网站有哪些资料wordpress 打赏实现
  • p2p金融网站建设无限白嫖国外云服务器
  • 四川广汉市规划和建设局网站网站建设登录结构图
  • 做网站一定要服务器吗android毕业设计代做网站
  • 企业专业网站建设做网站泉州
  • 在哪个网站找婚照公司做那个类型的网站赚钱
  • seo网站优化建议wordpress新闻动态插件
  • 城市中国商业网站平台建设银行网站扫码支付在哪里
  • 个人网站站长万网域名注册流程
  • mip网站建设网站制作报价多少
  • 网站建设中的思想和算法全球咨询公司最新排名
  • 外贸网站有什么个人网站怎么做联盟推广
  • 屏山县龙华镇中心村建设招标网站wordpress站群 企业
  • 番禺响应式网站开发青岛做家纺的公司网站
  • 网站建设项目外包合同范本南京城乡建设局网站
  • 云南建设工程有限公司网络seo优化推广
  • 外贸电商做俄罗斯市场网站兴化网站网站建设
  • 景点与网站合作方案怎么做求网站2021给个网址
  • 网站可信认证必须做网站建设需求说明
  • 网站制作的公司360建筑网兼职
  • 企业网站推广价格企业首页介绍
  • 做塑胶原料用什么网站好青岛市网站建设
  • 微网站是官网的手机站中铁建设集团有限公司招标平台
  • 免费织梦导航网站模板下载地址优化师是干嘛的