view跟camera組件同級
不要用bind:tap
和catch:tap
替換用catch:touchstart
即可解決!
如果你不放心,可以再加個透明蒙版,這樣就不會觸發了!(不加這個也行,但是必須要用catch:touchstart)
<!-- 相機層(橫屏適配) --><camera device-position="back" resolution="high" frame-size="large" style="width: 100%; height: 100vh;z-index:10;" catch:touchstart="cameraClick" id="myCamera"></camera><!-- 在camera組件同級添加 --><view style="{{shieldStyle}}" catch:touchstart="noop"></view><!-- 你的業務view內容 --><view>xxx</view>
onReady() {// 雙重保險:透明攔截層this.createTouchShield();},// 創建透明攔截層createTouchShield() {const query = wx.createSelectorQuery();query.select('#myCamera').boundingClientRect(rect => {console.log(rect)this.setData({shieldStyle: `position:absolute;left:${rect.left}px;top:${rect.top}px;width:${rect.width}px;height:${rect.height}px;z-index:999;pointer-events:auto;`});}).exec();},noop() {}, // 空函數吞噬所有事件