1、安装
npm i vue-awesome-mui --save
npm i vue-html5plus --save
2、main.js中引用
import Mui from 'vue-awesome-mui';
Vue.config.productionTip = false
Vue.use(Mui);
import VueHtml5Plus from 'vue-html5plus';
Vue.use(VueHtml5Plus);
3、调用
created() {
// 扩展API是否准备好,如果没有则监听“plusready"事件
if (window.plus) {
this.plusReady()
} else {
document.addEventListener('plusready', this.plusReady, false)
}
},
// 扩展API准备完成后要执行的操作
plusReady() {
const self = this
console.log("plusReady--", plus.geolocation);
plus.geolocation.getCurrentPosition(
function (p) {
console.log("onPlusReady--p.coords", p.coords);
self.positionXY = p.coords;
self.$store.state.location = p.coords;
},
function (err) {
console.log("onPlusReady--err", err);
}
);
},