更新记录
1.0.0(2021-05-26) 下载此版本
发布
平台兼容性
其他
多语言 | 暗黑模式 | 宽屏模式 |
---|---|---|
× | × | √ |
PC-拍照
通过调用电脑的摄像头,生成图片
兼容性
使用方式
在页面引入
<!-- 在项目中调起拍照功能 -->
<button @click="Init">PC拍照</button>
<!-- 不用插槽 -->
<pc-photo ref="pcPhoto" @send="send"></pc-photo>
<!-- 使用插槽 -->
<pc-photo ref="pcPhoto" @send="send">
<view>
<button @click="closePhoto">取消</button>
<button @click="takePhoto">拍摄</button>
<button @click="send">获取</button>
<button @click="retake">重拍</button>
</view>
</pc-photo>
import pcPhoto from '@/components/pc-photo/pc-photo.vue'
export default {
components: {pcPhoto},
methods: {
// 初始化
Init() {
this.$refs.pcPhoto.Init()
},
// 拍摄
takePhoto() {
this.$refs.pcPhoto.takePhoto()
},
// 关闭摄像头
closePhoto() {
this.$refs.pcPhoto.close()
},
// 重新拍照
retake() {
this.$refs.pcPhoto.cancal()
},
// 获取照片-base64
send(img) {
console.log(img)
}
}
}