framework7+vue+cordova移动开发(三)调用摄像头扫一扫

1.在某个.vue里面添加下面代码





2、在index.html 的引入cordova.js和cordova_plugins.js


  
<% if (process.env.TARGET === 'cordova') { %> <% } %>

3、app.js中加入


if (process.env.TARGET === 'cordova'){
  /* eslint-disable no-new */
  document.addEventListener('deviceready', function () {
    // Init App
    new Vue({
      el: '#app',
      panel: {
        swipe: 'left',
        leftBreakpoint: 768,
        rightBreakpoint: 1024,
      },
      render: (h) => h(App),
      // Register App Component
      components: {
        app: App,
        statusbarOverlay:false
      },
    });
    window.navigator.splashscreen.hide()
  }, false);
}else{
  new Vue({
    el: '#app',
    panel: {
      swipe: 'left',
      leftBreakpoint: 768,
      rightBreakpoint: 1024,
    },
    render: (h) => h(App),
    // Register App Component
    components: {
      app: App,
      statusbarOverlay:false
    },
  });
}

4、添加相应的插件
cordova plugin add phonegap-plugin-barcodescanner --save

然后自然就是打包测试了。

你可能感兴趣的:(cordova,framework7)