原来一直用 jQuery 。
最近上手 Vue.js ,感觉特爽。
可以部分脱离 jQuery 了。
非要直接操作 DOM 的 原生的 queryselector 感觉也够用了。
现在只剩下 XHR 这部分了,感觉不太喜欢 ES5 原生的。
所以求一个和 vuejs 配合使用的轻量 XHR js 库
![]() | 1 thinkif 2016-01-08 16:51:16 +08:00 |
![]() | 2 oxyflour 2016-01-08 17:11:51 +08:00 window.fetch ? https://developer.mozilla.org/en/docs/Web/API/Fetch_API |
![]() | 3 ChiangDi 2016-01-08 17:13:11 +08:00 window.fetch ,在不支持的浏览器上有 polyfill https://github.com/github/fetch |
4 doublleft 2016-01-08 17:17:44 +08:00 有机关枪不用,非要自己拿刀砍 |
![]() | 5 oott123 2016-01-08 17:48:11 +08:00 非要操作 DOM 还有 v-el 呢。 xhr 我比较喜欢 axios |
![]() | 6 heraldboy 2016-01-08 18:01:20 +08:00 我总感觉如果不是特别必要,没有必要折腾各种框架。 |
![]() | 7 loading 2016-01-08 20:22:27 +08:00 via iPhone 你搜索 jquery 替代,知乎有。 |
![]() | 8 laiqs2011 2016-01-08 21:44:03 +08:00 ![]() 直接使用 fetch API 不就足够了? 类似这样: fetch(`/api/resource/xxxxx`, { method: 'get', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } }).then(res => { return res.json(); }).then(json => { console.log('result', result); } }).catch(error => { console.log('error: ', error); }); 只兼容 chrome 的话,这么写是很爽的。 [https://github.com/github/fetch]( https://github.com/github/fetch) |
![]() | 9 alex321 2016-01-08 21:56:40 +08:00 一般工作一段时间的前端都会直接封装好多常用的类库吧,那都是原生的啊。。。 |
![]() | 10 void1900 2016-01-09 10:07:12 +08:00 zepto |