![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
前后端交互
苏喂苏喂苏喂su
专注前端开发
展开
-
根据不同的运行环境,自动切换不同的后台服务
export function getHost () { let host if (location.host === '指定的域名') { host = '指定的后台地址' } else { host = 'http://192.168.0.18:8092' // 本地开发服务器 } return { host }}...原创 2019-12-27 11:35:56 · 211 阅读 · 0 评论 -
web端直传文件到阿里云
核心方法:upload(e) { this.policy = Base64.encode(JSON.stringify(this.policyText)) this.audioName = e.target.files[0].name const type = this.getType(e.target.files[0].name) const key = Math.floo...原创 2019-12-19 11:50:12 · 414 阅读 · 0 评论 -
axios发post请求方法
axios({ url: '后端提供的接口地址', method: 'post', data: { code: 5016, data: { id: this.gifsId, employee: this.employee, giftCount: this.getPrice } }}).then(res => {...原创 2019-10-24 20:32:34 · 644 阅读 · 0 评论 -
axios发送options请求的问题
在项目过程中,发现某个请求一直无法成功,查看发现多了一个options请求,而该请求也一直没有响应。在网上查看了相关的资料,这是由浏览器发起的预检请求,目的是验证服务器是否支持自定义请求头,最后解决方案还是让后端过滤掉这个请求,问题才得以解决。...原创 2019-09-28 22:43:52 · 1127 阅读 · 1 评论