Vue调用Android的方法

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

1
2
3
4
5
<template>
  <div>
      <button @click="scan()">点击</button>
  </div>
</template>

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
export default {
  name: 'home',
  data () {
    return {
        arr:'123' //给安卓传参数,安卓需要定义参数类型
    }
  },
  methods:{
    scan: function(arr) {
        window.android.takePhoto(this.arr);
        //takePhoto()是安卓定义好的方法
    }      
  }
}

3、ojbk