camera 拍照后图片不能显示在image上,但是地址可以打开
发布于 6 年前 作者 lei08 4029 次浏览 来自 问答

.wxml

<image  class=“camera-style” src="{{srcurl}}"></image>

<camera class=“camera-style” id=“mycamera”  hidden="{{cameraisshow}}" device-position=“front”>

</camera>

<button class=“button-style” bindtap=“paizhaoclick”>拍照</button>

.wxss

.button-style {

width: 300rpx;

height: 60rpx;

margin-top: 12rpx;

}

.camera-style {

width: 240rpx;

height: 240rpx;

margin-top: 12rpx;

}

.js

var timer; // 计时器

Page({

onReady: function (res) {

this.myCamera = wx.createCameraContext(‘mycamera’)

},

data:{

// text:“这是一个页面”

cameraisshow:false,

srcurl:"",

},

paizhaoclick: function () {

var that = this;

this.myCamera.takePhoto({

quality: ‘normal’,

success: function (res) {

console.log(res);

var st = res.tempImagePath

console.log(st);

that.setData({ cameraisshow: true, srcurl: st });

},

fail: function (res) {

console.log(res);

}

});

},

})

运行效果:加载图片提示

VM878:2 Failed to load image http://127.0.0.1:63615/tmp/touristappid.o6zAJs_OfeJOCr-DMLPf2dV5xz98.rMRSn5pKtbWS8aaf18d7ce2c3f47f6b2ec57ae40f2df.jpg

net::ERR_EMPTY_RESPONSE ,但是点击路径是可以显示出来的,找不出问题在哪里…

回到顶部