vue 集成html5 plus - 懒懒de尐彪 - 博客园
首先要安裝一個包 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
} )
})
},
?
總結
以上是生活随笔為你收集整理的vue 集成html5 plus - 懒懒de尐彪 - 博客园的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 简单使用Git和Github来管理自己的
- 下一篇: 手机还能做电路仿真啊!电子电路兴趣爱好者