forked from wechat-miniprogram/miniprogram-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcanvas.js
45 lines (38 loc) · 791 Bytes
/
canvas.js
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
const example = require('./example.js')
Page({
onShareAppMessage() {
return {
title: '创建画布',
path: 'page/API/pages/canvas/canvas'
}
},
onLoad() {
this.context = wx.createContext()
const methods = Object.keys(example)
this.setData({
methods
})
const that = this
methods.forEach(function (method) {
that[method] = function () {
example[method](that.context)
const actions = that.context.getActions()
wx.drawCanvas({
canvasId: 'canvas',
actions
})
}
})
},
toTempFilePath() {
wx.canvasToTempFilePath({
canvasId: 'canvas',
success(res) {
console.log(res)
},
fail(res) {
console.log(res)
}
})
}
})