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