开发中常见问题汇总

95 阅读1分钟

js递归获取全部数据,在大量数据需要导出时非常实用

   getAllPasswordList() {
      return new Promise((resolve, reject) => {
        const func = () => {
          passwordList({ pageIndex: this.pageIndex, pageCount: 300, id: this.id }).then(res => {
            if (res.errorCode === 0 && res.data.list && res.data.list.length > 0) {
              this.list = [...this.list, ...res.data.list]
              this.pageIndex++
              func()
            } else {
              resolve(this.list)
            }
          }).catch(e => {
            reject(e)
          })
        }
        func()
      })
    },
react扩展语法传递属性
<Component {...props}></Component>