this.$apply()

2023-05-16

chooseVideo(e) {
this.fileInfo = {}
let that = this
wx.chooseVideo({
sourceType: ['album', 'camera'],
maxDuration: 60,
camera: 'back',
success: function(res) {
that.fileInfo = res
that.$apply()   // 页面有变化
}
})
this.$apply() // 页面无变化
}
 

<view>
<view wx:if="{{fileInfo.thumbTempFilePath===undefined}}">
<view>
<image src="{{notHere.commonCfg.localImgPath}}icon-plus-16.svg" @tap="chooseVideo(e)"></image>
</view>
</view>
<view wx:else>
<view @tap="chooseVideo(e)">
<video src="{{fileInfo.tempFilePath}}" enable-danmu danmu-btn autoplay poster="{{fileInfo.thumbTempFilePath}}"></video>
</view>
</view>
</view>
 
 

this.$apply()的相关教程结束。

《this.$apply().doc》

下载本文的Word格式文档,以方便收藏与打印。