安装mui
npm i vue-awesome-mui
在main.js 文件中引入
import Mui from 'vue-awesome-mui';
Vue.use(Mui);
需要用到H5Plus 的地方首先需要:
methods:{
// 扩展API准备完成后要执行的操作
plusReady () {
var ws = plus.webview.currentWebview(); //pw回车可输出plus.webview
},
}
created () {
// 扩展API是否准备好,如果没有则监听“plusready"事件
if (window.plus) {
this.plusReady()
} else {
document.addEventListener('plusready', this.plusReady, false) //
}
}
比如在项目中需要调用拍照的方法:
调用拍照
获取位置信息
选择日期
首页
getImage() {
let cmr = plus.camera.getCamera(); // 获取摄像头对象
let res = cmr.supportedImageResolutions[0]; // 字符串数组,摄像头支持的拍照分辨率
let fmt = cmr.supportedImageFormats[0]; // 字符串数组,摄像头支持的拍照文件格式
console.log("Resolution :" + res + ", Format: " + fmt);
cmr.captureImage(
path => {
alert("调用成功: " + path);
},
error => {
// 拍照操作失败的回调函数
alert("调用失败: " + error.message);
},
{ resolution: res, format: fmt } // 摄像头拍照参数
);
}
打包
npm run build
真机运行