I opened a similar issue recently but found this thread now.
@pixelijn’s example works perfectly for image block, but it does not work for gallery block. This is part of my Vue code for block preview:
data() {
return {
captions: {}
};
},
created() {
this.captionsLoader();
},
methods: {
captionsLoader() {
if(this.content.images) {
for(let img of this.content.images) {
this.$api.get(img.link).then(image => {
this.captions[img.id] = image.content.caption;
});
}
}
}
},
I have a field called caption in file blueprint and I want to load its value into block preview. However, using the above approach I’m not able to load the captions during the initial page load. I mean the values are loaded (I can console.log them or simply see them in Vue DevTools), but not rendered. The captions are rendered only after making changes on the page. Refreshing the page causes them to disappear again.
I assume the values arrive late, just after the component is rendered. Is there any way to fix this?