您好,我在复现您的代码<【鸿蒙应用ArkTS开发系列】- 选择图片、文件和拍照功能实现>时候,出现一个问题,
调用相机拍照后无法显示拍照的图片,并且返回url是空值。
错误项为
11-27 21:53:22.301 30935-11718/com.example.myapplication E 03900/Ace: [jsi_declarative_engine.cpp(CallAppFunc)-(0)] property "default" is not a object
拍照类中startAbility call back的值result是空值
11-27 21:53:26.407 30935-11718/com.example.myapplication I 0FEFE/JsApp: MediaHelper startAbility call back , {"resultCode":0,"want":{"deviceId":"","bundleName":"","abilityName":"","moduleName":"","uri":"","type":"","flags":0,"action":"inline-data","parameters":{"data":{},"moduleName":""},"entities":[]}}
11-27 21:53:26.407 30935-11718/com.example.myapplication I 0FEFE/JsApp: 进入拍照类003,uri:undefined
下方是图片
出问题的代码
public async takePhoto(context: common.UIAbilityContext): Promise<MediaBean> {
console.info("进入拍照类")
let want = {
'uri': '',
'action': wantConstant.Action.ACTION_IMAGE_CAPTURE,
'parameters': {},
};
console.info("进入拍照类001")
return context.startAbilityForResult(want)
.then((result) => {
console.info("进入拍照类002")
console.info(this.TAG, `startAbility call back , ${JSON.stringify(result)}`);
if (result.resultCode === 0 && result.want &&(result.want.uri==null||result.want.uri=="")==false) {
//拍照成功
// console.info(this.TAG, 'takePhoto successfully, takePhotoResult uri: ' + result.want.uri);
return result.want.uri;
}
}).catch((error) => {
console.info("进入拍照类error")
console.info(this.TAG, `startAbility error , ${JSON.stringify(error)}`);
return error;
}).then(async (uri: string) => {
console.info("进入拍照类003,uri:"+uri)
const mediaBean = await this.buildMediaBean(uri);
return mediaBean;
});
}
麻烦解惑
附件地址:https://download.csdn.net/download/weixin_38808271/88582792?spm=1001.2014.3001.5503