wx.chooseMedia({
count: 1,
success(res) {
// tempFilePath可以作为 img 标签的 src 属性显示图片
const tempFiles = res.tempFiles
const src = tempFiles[0]['tempFilePath'];
var img = new Image();
img.src = src;
img.onload = function (info) {
let texture = new cc.Texture2D();
texture.initWithElement(img);
texture.handleLoadedTexture();
cb && cb(new cc.SpriteFrame(texture))
};
img.onerror = function (err) {
// console.warn(err)
}
}
})
1赞
