Skip to content

Commit cbcb40e

Browse files
authored
Merge pull request #23 from ZackJiang21/master
fix multi canvas in one page caused id conflict issue
2 parents f8c39e9 + 7767793 commit cbcb40e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/components/fabric/fabric.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div>
3-
<canvas id="canvas" :width="width" :height="height"></canvas>
3+
<canvas :id="id" :width="width" :height="height"></canvas>
44
</div>
55
</template>
66

@@ -11,6 +11,10 @@ const rotateMdrImg = require('../../assets/rotate-mdr.png');
1111
export default {
1212
name: 'VueFabric',
1313
props: {
14+
id: {
15+
type: String,
16+
default: 'canvas',
17+
},
1418
width: {
1519
type: Number,
1620
required: true
@@ -221,7 +225,7 @@ export default {
221225
},
222226
freeDrawConfig (options) {
223227
options = Object.assign({color:'#b2b2b2',drawWidth:2},options);
224-
228+
225229
this.canvas.isDrawingMode = options.isDrawingMode;
226230
this.canvas.freeDrawingBrush.color = options.color; // 设置自由绘颜色
227231
this.canvas.freeDrawingBrush.width = options.drawWidth;
@@ -631,4 +635,4 @@ export default {
631635
</script>
632636

633637
<style lang='scss' scoped>
634-
</style>
638+
</style>

0 commit comments

Comments
 (0)