I am currently working with multiple instances of a polygonCrop component in Vue.js, each one having a unique reference to a canvas property. These components are utilized in separate crop functions triggered by button clicks. My question is how to effectively use multiple refs with multiple components in Vue.js?
<polygonCrop
:canvasClass="'some-class'"
:height="600"
:imageSource="imgSrc"
:showCanvas="show"
:showPointer="showPointer"
:width="800"
ref="canvas"
></polygonCrop>
<polygonCrop
:canvasClass="'some-class'"
:height="600"
:imageSource="imgSrc1"
:showCanvas="show"
:showPointer="showPointer"
:width="800"
ref="canvas1"
></polygonCrop>
...
<b-button @click.prevent="crop" variant="success">Crop</b-button>
<b-button @click.prevent="crop1" variant="success">Crop</b-button>
...
crop: function () {
this.$refs.canvas.crop();
this.resultImage = this.$refs.canvas.resultImage;
this.show = false;
this.showResult = true;
},
crop1: function () {
this.$refs.canvas1.crop();
this.resultImage1 = this.$refs.canvas1.resultImage;
this.show = false;
this.showResult = true;
},
Although I am utilizing multiple canvases with references like canvas
and canvas1
, I'm unsure if this is the correct approach. Any guidance on this matter would be greatly appreciated.