fix:添加自定义组件
This commit is contained in:
parent
7cd41cd991
commit
2dd09fcfa5
|
|
@ -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>
|
||||||
Loading…
Reference in New Issue