demo.js
Page({
onReady: function () {
const cameraCtx = wx.createCameraContext()
const cameraCfl = cameraCtx.onCameraFrame(res => {
const data = new Uint8ClampedArray(res.data);
wx.canvasPutImageData({
x: 0,
y: 0,
width: 300,
height: 150,
data,
success: res => {
console.log('绘制成功:', res)
},
fail: res => {
console.log('绘制失败:', res)
},
complete: res => {
console.log(res)
}
})
})
cameraCfl.start()
}
})
demo.wxml
demo.wxss
page{
height: 100%;
}
.container {
height: 100%;
}