1. var baseUrl ="https://music.aityp.com/"
    2. function http({url,data,callback}){
    3. wx.request({
    4. url: baseUrl+url,
    5. data: {},
    6. header: {'content-type':'application/json'},
    7. method: 'GET',
    8. dataType: 'json',
    9. responseType: 'text',
    10. success: (res)=>{
    11. callback(res)
    12. }
    13. });
    14. }
    15. module.exports = http;
    16. 调用
    17. const http = require('../../util/http.js');
    18. Page({
    19. data: {
    20. },
    21. onLoad: function (options) {
    22. http({
    23. url:"mv/first",
    24. callback:this.handleData
    25. })
    26. },
    27. handleData(res){
    28. console.log(res)
    29. }
    30. })