🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
http.js ``` class HTTP { request({ url, type = "get", dataType }) { return $.ajax({ url, type, dataType }) } } class MovieModel extends HTTP{ getTop250(){ return this.request({ url:"https://api.douban.com/v2/movie/top250", dataType:"jsonp" }) } } ``` index.js ``` <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script> <script src="http.js"></script> ``` ``` <script> var http = new HTTP(); http.request({ url:"https://api.douban.com/v2/movie/top250", dataType:"jsonp", success: res=>{ console.log(res) } }) </script> ```