Skip to content

Commit

Permalink
fix(h5): 修复measureText返回undefined的问题, close #4254
Browse files Browse the repository at this point in the history
  • Loading branch information
Littly committed Aug 26, 2019
1 parent 80642bc commit bca1733
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions packages/taro-h5/src/api/canvas/createCanvasContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,35 +162,35 @@ const createCanvasContext = (canvasId, componentInstance) => {
]

const functionProperties = [
'arc',
'arcTo',
'beginPath',
'bezierCurveTo',
'clearRect',
'clip',
'closePath',
'createCircularGradient',
'createLinearGradient',
'createPattern',
'drawImage',
'fill',
'fillRect',
'fillText',
'lineTo',
'measureText',
'moveTo',
'quadraticCurveTo',
'rect',
'restore',
'rotate',
'save',
'scale',
'setTransform',
'stroke',
'strokeRect',
'strokeText',
'transform',
'translate'
['arc'],
['arcTo'],
['beginPath'],
['bezierCurveTo'],
['clearRect'],
['clip'],
['closePath'],
['createCircularGradient'],
['createLinearGradient'],
['createPattern'],
['drawImage'],
['fill'],
['fillRect'],
['fillText'],
['lineTo'],
['measureText', true],
['moveTo'],
['quadraticCurveTo'],
['rect'],
['restore'],
['rotate'],
['save'],
['scale'],
['setTransform'],
['stroke'],
['strokeRect'],
['strokeText'],
['transform'],
['translate']
]

const valueProperties = [
Expand Down Expand Up @@ -227,11 +227,11 @@ const createCanvasContext = (canvasId, componentInstance) => {
})
})

functionProperties.forEach(funcName => {
functionProperties.forEach(([funcName, isSync]) => {
Object.defineProperty(CanvasContext, funcName, {
get () {
return enqueueActions(ctx[funcName])
},
get: isSync
? () => ctx[funcName].bind(ctx)
: () => enqueueActions(ctx[funcName]),
enumerable: true
})
})
Expand Down

0 comments on commit bca1733

Please sign in to comment.