I am generating a base64 string that represents an image and trying to pass that image data to a child component as the property of an object.
This is the class for my object that I want to pass to my child component. It has an image property as well as a few other properties. When my parent component changes otherData or id, things work fine. I will see the updated value in my child component. However, when image changes, I do not see the new image until I change a DIFFERENT property on my instance of MyDataModel! For example, if I change otherData, the new image suddenly appears on the screen. I am wondering if image is simply too big for Vue's change detection to handle. It's a base64 string to represent a 320x240 image, about 150KB in size. Hower, if I take out image and declare it as a string property on my parent component...then the child component shows the updated image every time without fail.
export default class MyDataModel { public id!: string; public image!: string; public otherData: string; constructor(init?: Partial<MyDataModel>) { Object.assign(this, init); } } In my parent component, this is how I declare a new object representing the data for my child component
private childData = new MyDataModel(); In my parent component, this is how I create the image:
const data = this.$refs.cameraCanvas.toDataURL('image/png'); this.capturedImageData = data; Then, I assin my image property to capturedImageData
this.childData.image = this.capturedImageData; childData is a property of my child component
<ChildComponent :data="childData"></ChildComponent> This is how I declare my data property in the child component
@Prop({required: true}) private data!: MyDataModel // MyDataModel is a typscript class with an image property Lastly, this is how I am trying to show the image
<b-img id="input-image" :src="data.image"></b-img>