1.0.8 • Published 6 years ago

vue-image-select v1.0.8

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

vue-image-select

Step 1: Install

yarn add vue-image-select

or

npm install vue-image-select --save

Step 2: Config @ Laravel_Project/resources/assets/js/app.js

window.Vue = require('vue');
require('vue-image-select');

or

Vue.use(require('vue-image-select'));

Step 3: Template

<button class="btn btn-primary" @click="addPhotos">Save</button>
<vue-image-select :images="dataImages" v-model="updatingPhotos"></vue-image-select>

Step 4: Data

data() {
    return {
        updatingPhotos: [],
        // Init Selected, invalid id will be ignored
        // updatingPhotos: [3, 11],
        dataImages: []
    }
}

Step 5: dataImages Load Sample

loadPhotos: function() {
    let self = this;
    self.instance
        .get('/api/photos/')
        .then(function(response) {
            // id is required
            // [{"id" => 1, "url" => "a.jpg"}, {"id" => 2, "url" => "b.jpg"}]
            self.dataImages = response.data.data
        })
},

Step 6: Sample for action after multi-selecting images

addPhotos: function(id) {
    let self = this

    var formData = new FormData();
    formData.set('_method', "PUT");
    formData.set("photo_ids", self.updatingPhoto.join(','));

    axios.post("/api/products/" + id, formData)
        .then(function (response) {
            // TODO: succeed
        }).catch(function (error) {
            // TODO: error
        }).then(function() {
            self.updatingPhotos = []
        });
},

Data Props

NameSampleDescription
:imagesdataImagesarray for images viewed in the component
v-modalupdatingPhotosarray for fetch selected images(get), or init selected photos, ignore invalid id(set)

References

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago