W3Cschool
恭喜您成為首批注冊(cè)用戶(hù)
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
解釋?zhuān)号恼?,可指定質(zhì)量,成功則返回圖片。
Object object
參數(shù)名 | 類(lèi)型 | 必填 | 默認(rèn)值 | 說(shuō)明 |
---|---|---|---|---|
quality | String | 否 | normal | 成像質(zhì)量,有效值為 high, normal, low。 |
success | Function | 否 | 接口調(diào)用成功的回調(diào)函數(shù),res = { tempImagePath }。 | |
fail | Function | 否 | 接口調(diào)用失敗的回調(diào)函數(shù) | |
complete | Function | 否 | 接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會(huì)執(zhí)行) |
<div class="camera">
<camera device-position="{{device}}" flash="off" binderror="error" style="width: 100%; height: 500rpx;"></camera>
<button type="primary" bind:tap="takePhoto">拍照</button>
<image class="img" mode="widthFix" src="{{src}}"></image>
</div>
Page({
data: {
src: ''
},
takePhoto() {
const cameraContext = swan.createCameraContext();
cameraContext.takePhoto({
// quality的可選值:normal-正常, low-低質(zhì)
quality: 'high',
success: res => {
this.setData({
src: res.tempImagePath
});
}
});
}
});
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話(huà):173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: