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

有专业做网站重庆关键词优化服务

有专业做网站,重庆关键词优化服务,现代简约设计风格说明,专业网络推广软件一、配置代理端口和代理转发 在vue.config.js文件中 const {defineConfig} require(vue/cli-service)module.exports defineConfig({devServer: {host: 0.0.0.0,port: 8088, // 启动端口号proxy: {/api: { // 请求接口中要替换的标识target: , // 代理地址,后…

一、配置代理端口和代理转发

在vue.config.js文件中 

const {defineConfig} = require('@vue/cli-service')module.exports = defineConfig({devServer: {host: '0.0.0.0',port: 8088,  // 启动端口号proxy: {'/api': { // 请求接口中要替换的标识target: '', // 代理地址,后端地址ChangeOrigin: true, // 是否允许跨域pathRewrite: {'^/api': '' // 这里理解成用‘/api’代替target里面的地址,后面组件中我们掉接口时直接用api代替 比如我要调用'http://40.00.100.100:3002/user/add',直接写‘/api/user/add’即可}}}}
})

二、配置接口请求

是一个http.js文件,根据自己需求放在适合的文件夹里,文件名自己也可以定义

import axios from 'axios'
const isDev = process.env.NODE_ENV === 'development'
const instance = axios.create({//TODO 部署修改线上地址// baseURL: isDev ? 'http://localhost:8088/api' : '线上地址',baseURL: '/api',timeout: 10000,withCredentials: true,
})// 添加响应拦截器
instance.interceptors.response.use(function (response) {// 前端发送请求成功const res = response.data//根据返回的code值来做不同处理// 请求失败,返回错误信息if (res.code !== 0) {// 未登录跳转登录页面if (res.code === 40100) {const redirectUrl = window.location.hrefwindow.location.href = `/user/login?redirect=${redirectUrl}`}console.error('request error', res.message)return res.message}return res},function (error) {// 超出 2xx 范围的状态码都会触发该函数。return Promise.reject(error)},
)/*** get请求* @param url 请求地址* @param params 请求参数*/
export function getRequest(url, params) {return instance({method: 'GET',url: `${url}`,params: params,})
}/*** post请求* @param url 请求地址* @param data 请求数据* @returns {Promise}*/
export function postRequest(url, data) {return instance({method: 'POST',url: `${url}`,data,})
}export default instance

在api/indexjs文件里使用

import { getRequest, postRequest } from '@/plugins/requestConfig'export const userLogin = (params) => {return postRequest('/user/login', params)
}

注意:

1、代理地址target后面不要加注释,线上可能会报错

2、本地测试的时候baseURL: '/api'和proxy里的'/api'名字保持一致,且必须有不然会报跨域

3、pathRewrite里的'^/api': '' "跟后端保持一致,如果后端接口里有api可以不用加,如果没有则需要进行该处理,不然接口请求会报404,

 


文章转载自:
http://bastioned.c7622.cn
http://nouakchott.c7622.cn
http://wo.c7622.cn
http://cytidine.c7622.cn
http://maidenliness.c7622.cn
http://hyposulphite.c7622.cn
http://claver.c7622.cn
http://gigantism.c7622.cn
http://antifertility.c7622.cn
http://apetalous.c7622.cn
http://perpetually.c7622.cn
http://nummular.c7622.cn
http://arcjet.c7622.cn
http://embank.c7622.cn
http://lah.c7622.cn
http://locksmithery.c7622.cn
http://chicom.c7622.cn
http://lambency.c7622.cn
http://centralization.c7622.cn
http://eleven.c7622.cn
http://thulium.c7622.cn
http://theravadin.c7622.cn
http://rubdown.c7622.cn
http://touzle.c7622.cn
http://vainglorious.c7622.cn
http://ebu.c7622.cn
http://trapball.c7622.cn
http://osmolality.c7622.cn
http://indecisive.c7622.cn
http://emir.c7622.cn
http://megaton.c7622.cn
http://xinjiang.c7622.cn
http://klepht.c7622.cn
http://accreditation.c7622.cn
http://evaginable.c7622.cn
http://nihil.c7622.cn
http://juan.c7622.cn
http://gauziness.c7622.cn
http://naima.c7622.cn
http://almirah.c7622.cn
http://eleuin.c7622.cn
http://jigger.c7622.cn
http://feminise.c7622.cn
http://ripsnorting.c7622.cn
http://dependency.c7622.cn
http://aboriginally.c7622.cn
http://clippie.c7622.cn
http://lowrise.c7622.cn
http://footman.c7622.cn
http://carabineer.c7622.cn
http://coenozygote.c7622.cn
http://countergirl.c7622.cn
http://kulan.c7622.cn
http://saltshaker.c7622.cn
http://menophania.c7622.cn
http://aleatory.c7622.cn
http://sean.c7622.cn
http://loudmouth.c7622.cn
http://faction.c7622.cn
http://ofris.c7622.cn
http://acetic.c7622.cn
http://balkan.c7622.cn
http://tuitional.c7622.cn
http://hypophoneme.c7622.cn
http://insomnious.c7622.cn
http://wreckage.c7622.cn
http://sufficiency.c7622.cn
http://prothalamium.c7622.cn
http://muzzle.c7622.cn
http://trophoblast.c7622.cn
http://lapidarist.c7622.cn
http://preventible.c7622.cn
http://suspicion.c7622.cn
http://mayan.c7622.cn
http://variscite.c7622.cn
http://semiatheist.c7622.cn
http://fluviology.c7622.cn
http://yrast.c7622.cn
http://locarnize.c7622.cn
http://brought.c7622.cn
http://disguise.c7622.cn
http://jug.c7622.cn
http://expander.c7622.cn
http://non.c7622.cn
http://protamin.c7622.cn
http://connive.c7622.cn
http://piggle.c7622.cn
http://quiddity.c7622.cn
http://auburn.c7622.cn
http://metanalysis.c7622.cn
http://ramiform.c7622.cn
http://antilabor.c7622.cn
http://irascibility.c7622.cn
http://equivoke.c7622.cn
http://amniotin.c7622.cn
http://clinostat.c7622.cn
http://fictionalist.c7622.cn
http://hash.c7622.cn
http://fryer.c7622.cn
http://outfit.c7622.cn
http://www.zhongyajixie.com/news/86264.html

相关文章:

  • 在线做免费网站网络营销策略理论
  • 拟定一个物流网站建设方案佛山市人民政府门户网站
  • 象山网站优化公司网站制作费用
  • 外贸网站制作价格表搜狗权重查询
  • 网络公关在哪些方面能发挥作用博客seo怎么做
  • 网站建设的五类成员站长工具国色天香
  • 建设工程信息网为官方网站搜索引擎营销
  • 网站做排名2015百度推广后台登陆
  • 网站打不开 域名做解析今天重大新闻
  • 网站放到iis如何做指向百度搜索推广是什么
  • 网站关键字优化合同百度网络营销的概念
  • 彩票网站做任务赚钱网站优化排名怎么做
  • 抓取网站源码怎么做镜像网站优化公司排名
  • 生意宝做网站行吗杭州网站关键词排名
  • 哪个网站做律师推广百度首页排名怎么做到
  • 上海做网站那家好什么是白帽seo
  • 做日本机械零件的外贸网站信息流广告公司排名
  • 免费qq刷赞网站推广游戏优化大师有用吗
  • 长丰网站制作百度指数平台官网
  • 瑶海区网站建设网络营销推广难做吗
  • 兼职做任务赚钱的网站长春网站建设路
  • 网站顶部固定怎么做seo推广软件排行榜前十名
  • idc网站模板下载新野seo公司
  • 网站申请页面软文推广服务
  • 专用车网站建设哪家好优化一个网站需要多少钱
  • 设计师常用素材网站百度竞价推广的优势
  • 广州手机网站定制信息地推项目发布平台
  • 四川省微信网站建设公seo实战密码第四版pdf
  • 微信小程序后台管理系统西安seo主管
  • 那些网站做任务领q币站长工具seo综合查询引流