uniapp uview 1.0 跨域h5配置多个代理、如何请求接口

参考文章:uniapp uView1.0跨域h5配置多个代理
官方手册:http 请求

项目中使用:

参考其他博主的文章是在manifest.json中配置代理,但在官方的手册中是直接在script请求的,我尝试请求了下没问题,上线后也不存在跨域问题,数据直接拿到了(有点懵)

官方手册中是在onload中请求的,实际项目中我是放在created中也ok。

下面附上官方请求get、post的示例

<script>
	export default {
    
    
		onLoad() {
    
    
			// 不带header
			this.$u.post('http://www.example.com', {
    
    
				id: 3,
				menu: 1
			}).then(res => {
    
    
				console.log(res);
			});
			
			// 带上header(对象形式),由于header为第三个参数,如果不需要请求参数,第二个参数传一个空对象"{ }"即可
			this.$u.get('http://www.example.com', {
    
    }, {
    
    
				token: 'xyz'
			}).then(res => {
    
    
				console.log(res);
			});
		}
	}
</script>