dfws-taro-upload

东方网升 taro 版本上传组件

Usage no npm install needed!

<script type="module">
  import dfwsTaroUpload from 'https://cdn.skypack.dev/dfws-taro-upload';
</script>

README

东方网升 taro 版本上传组件

发布

  1. 更改package.json版本
  2. yarn run build:compoent
  3. npm publish 注:镜像源需切换回NPM官方源

链接

示例

  • yarn
  • yarn run dev:weapp

使用之前

该组件依赖于taro,使用之前请配置taro。

何时使用

  • 需要oss文件上传。

API

<Upload url='https://oss-service.dfwsgroup.com/oss?sourceId=1&detailId=2' onGetUpload={this.getUpload} />
getUpload = (upload) => {
  this.setState({
    upload: upload,
  })
}
chooseFile = () => {
  const { upload } = this.state
  Taro.chooseImage({
    count: 5,
    success: (res) => {
      upload(res.tempFilePaths).then(fileUrls=>{
        this.setState({
          files:this.state.files.concat(fileUrls)
        })
      })
    }
  })
}

upload props

参数 说明 类型 默认值
url 获取oss数据的接口 string -
onGetUpload 获取上传方法实例 function -

返回值

uploader实例对象 接收本地临时文件路径列表 成功后返回文件地址 Array

参考文档

微信小程序api