微信小程序视频上传

wxml代码

<view class="app">
  <view class="container">
    <video src="{{src}}">video>
    <button data-type="album" bindtap="bindButtonTap">相册button>
  <button data-type="camera" bindtap="bindButtonTap">相机button>
view>
view>

js代码

  bindButtonTap: function (e){
    var that = this;
    console.log(e);
    var opentype=e.currentTarget.dataset.type;
    //opentype
    console.log(opentype);
    wx.chooseVideo({
      sourceType: ['"'+opentype+'"'],
      maxDuration: 60,
      camera: 'back',
      success: function (res) {
        that.setData({
          src: res.tempFilePath
        })
      }
    })
  }

你可能感兴趣的:(小程序)