Skip to content

Instantly share code, notes, and snippets.

View zjkal's full-sized avatar
🟢
online

zjkal

🟢
online
View GitHub Profile
@zjkal
zjkal / gist:4cfd38dc1090a077a313fc2e613a9de8
Created July 27, 2020 18:17
uniapp封装网络请求(自动传入token)
//封装uniapp的网络请求, 可以简单的通过$.get()或者$.post()发起请求, 而且可以自动传入token
let ajax = function(opt) {
opt = opt || {};
opt.method = opt.method.toUpperCase() || 'GET';
opt.url = opt.url || '';
opt.data = opt.data || {};
opt.success = opt.success || function() {};
opt.showLoading = opt.showLoading || false;
//如果缓存中存在token, 则装入请求