原生IOS嵌入vue打包的H5,在H5中调用原生摄像头扫码,且扫描回调返回数据
<div class="code"> <img class="scan" src="../assets/images/scan.png" alt="" @click.stop="openQrcode('camera')" /> <input class="input" type="number" placeholder="请输入核销码1" v-model="code" /> </div>
methods: { // ios的扫码回调 camera(str){ this.code=str; }, openQrcode() { window.webkit.messageHandlers.toscan.postMessage('camera') } }, created: function () { window.camera = this.camera; },