1、在vue页面中自己写个按钮,通过点击按钮来调用Android封装好的方法。

<template>
  <div>
      <button @click="scan()">点击</button>
  </div>
</template>

2、点击时咱们给安卓传个参数,安卓定义好参数类型。

export default {
  name: 'home',
  data () {
    return {
        arr:'123' //给安卓传参数,安卓需要定义参数类型
    }
  },
  methods:{
    scan: function(arr) { 
        window.android.takePhoto(this.arr);
        //takePhoto()是安卓定义好的方法
    }      
  }
}

3、ojbk

Logo

前往低代码交流专区

更多推荐