1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| toPicture: false
toIMG() { this.toPicture = true; uni.showLoading({ mask: true, title: "生成中..." });
const ctx = uni.createCanvasContext("save-picture"); ctx.fillText('Hello', 20, 20); ctx.fillText("能不能?图片啊啊啊啊呀呀呀", 50, 20);
const _this = this; ctx.draw(false, () => { uni.canvasToTempFilePath({ canvasId: "save-picture", width: 376 * 4, height: 500 * 4, quality: 1, fileType: 'jpg', success: (res) => { console.log(res.tempFilePath); uni.hideLoading(); uni.previewImage({ urls: [res.tempFilePath], longPressActions: { itemList: ['发送给朋友', '保存图片', '收藏'], success(data) { console.log("点击了第" + (data.tapIndex + 1) + "个按钮"); } } }) }, }, _this); }); }
|