mazipan / vue-select-image

✅ Vue 2.x component for selecting image from list

Home Page:https://mazipan.github.io/vue-select-image/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

set initial selection

ad34 opened this issue · comments

commented

I'm currently trying to set an initial selection but looks like filling the array declared in @onselectmultipleimage but update the selection. is there any way to do this?

Not possible for now, but I can add in next release.
Or if you want di your own implementation, just fork and feel free to open pull request.
I will review your code.

Thanks

commented

You can do it by accessing the reference directly.
For example:

<vue-select-image ref="imageSelector"></vue-select-image>

For multiple selection:

const images = [
    { id: '...', src: '...'},
    //...
];
this.$refs.imageSelector.multipleSelected = images;

For single selection (not tested):

const image_id = '...';
this.$set(this.$refs.imageSelector.singleSelected, 'id', image_id);

I do not recommend using $refs, use props :selectedImages with Array type.
You can also doing for singleSelection with same way.