<template>
<view class="inner">
<view class="content">
<image :src="imageList"></image>
<view class="btn" @click="getPho()">
点击拍照
</view>
<view class="btn" @click="delPho()" style="bottom: 10rpx;">
取消
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
imageList: ''
}
},
methods: {
getPho() {
// 1.
const that = this;
uni.chooseImage({
count: 6, // 最多可以选择的图片张数,默认9
sizeType: ['original'], //original 原图,compressed 压缩图,默认二者都有
sourceType: ['album', 'camera'], //album 从相册选图,camera 使用相机,默认二者都有。如需直接开相机或直接选相册,请只使用一个选项
success: function(res) {
that.imageList = res.tempFilePaths[0]
}
})
},
delPho(){
this.imageList=''
}
},
onReady() {}
}
</script>
<style lang="scss" scoped>
.inner {
width: 100%;
height: 100vh;
}
.content {
position: relative;
width: 100%;
height: 100vh;
background-color: #909399;
image {
width: 100%;
height: 100vh;
}
}
.btn {
width: 95%;
height: 90rpx;
text-align: center;
line-height: 90rpx;
position: absolute;
right: 20rpx;
bottom: 100rpx;
background-color: red;
color: #FFFFFF;
}
</style>
uniapp撰写app调用手机摄像头拍摄图片及选择相册图片
最新推荐文章于 2024-05-29 15:33:00 发布