vue 集成html5 plus


首先要安装一个包 vue-html5plus 

  npm i vue-html5plus -S

然后配置这个文件

在main.js添加一串代码

  var onPlusReady = function (callback, context = this) {

    if (window.plus) {

      callback.call(context)

     } else {

      document.addEventListener('plusready', callback.bind(context))

     }

  }

  Vue.mixin({

     beforeCreate () {

      onPlusReady(() => { this.plusReady = true }, this)

     },

    methods: {

      onPlusReady: onPlusReady

    }

  })

这样就可以集成html5 plus了

使用方法示例:(获取地理位置)

  mounted () {

    this.onPlusReady(function () {

      plus.geolocation.getCurrentPosition( 

         this.geoInf, function (e) {

          alert('获取位置信息失败:' + e.message)

        },

         {

           geocode: false

        } )

     })

   },

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM