fix:添加自定义组件

This commit is contained in:
shijing 2025-03-26 17:21:06 +08:00
parent 7cd41cd991
commit 2dd09fcfa5
1 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,34 @@
<template>
<div>
<el-button type="primary" @click="scanCode" style="margin-left: 10px">扫码</el-button>
</div>
</template>
<script>
export default {
data() {
return {
scannedResult: null, //
};
},
mounted() {
window.onScanResult = this.onScanResult;
},
methods: {
scanCode(){
if (window.Android) {
window.Android.openScanner();
} else {
alert("当前环境不支持扫码");
}
},
onScanResult(data) {
this.scannedResult = data;
this.$emit('scanResult', data);
return data;
},
},
};
</script>
<style></style>