← 全部文章
uniapp前端踩坑

uniapp 网页跨域请求踩坑

约 1 分钟SIKUAI

请求失败: {errMsg: "request:fail abort"}
通过common/config.js进行配置

// config.js
const baseUrl = 'https://sikuai2333.github.io/';

export default {
  baseUrl
}

页面

fetchPageConfig(page) {
				const url = `${page}`;
				// const url = `${config.baseUrl}${page}`;
				console.log(url)

如果直接请求https://sikuai2333.github.io/main.txt会报错\ 但是请求${config.baseUrl}main.txt就不报错