<template>
<view class="camera-page">
<image :src="imgSrc" v-if="imgSrc"/>
<button @click="openCamera">拍照</button>
</view>
</template>
<script>
// import plus from '@/common/plus.js'
export default {
data () {
return {
imgSrc: ''
}
},
methods: {
openCamera () {
plus.camera.getCamera().captureImage((path) => {
console.log(path)
this.imgSrc = path
}, (err) => {
console.error('拍照失败:', err)
})
}
}
}
</script>
<style>
.camera-page {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.camera-page image {
width: 200px;
height: 200px;
margin-bottom: 20px;
}
</style>