vue使用html5,vue项目中使用H5+

安装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

真机运行

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值