对象解构传参

http-p.js

// 对象解构的方式传参
  request({url, data={}, method='GET'}) {
    return new Promise((resolve, reject)=>{
      // 正常调用参数 url, data, method
      this._request(url, resolve, reject, data={}, method='GET')
    })

 

book.js

import {
  HTTP
} from '../util/http-p.js'

class BookModel extends HTTP {
  getHotList() {
    return this.request({    // 用对象的方式传参
      url: 'book/hot_list'
    })
  }
}

 

posted @ 2019-04-03 19:18  254980080  阅读(836)  评论(0编辑  收藏  举报