A Vue mixin that allows you to get resource data from FlexibleResource which is a Laravel package.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
src
.babelrc
README.md
package-lock.json
package.json

README.md

v-flexible-resource

A Vue mixin that allows you to get resource data from FlexibleResource which is a Laravel package.

Installation

npm i v-flexible-resource --save

Dependency

This package uses axios to get resource data through Ajax.

Usage

Basic usage

This package automatically calls Vue.mixin().
So, you don't need to set mixins.

<script src="/PATH/TO/YOUR/FOLDER/v-flexible-resource/resource.js"></script>
<script>

    new Vue({
        el: '#app',
        data: {
            userTypes: {},
            userTypeCollection: []
        },
        mounted() {

            var keys = ['userTypes', 'userTypeCollection'];
            this.resource(keys);

        }
    })

</script>

Callback

The second argument of resource() is for callback.
And callback has resource data.

this.resource(keys, function(data){

    console.log(data);

});

Resource URL

You can change resource URL by overwriting resourceUrl.

new Vue({
    el: '#app',
    data: {
        resourceUrl: '/YOUR/RESOURCE/URL'
    },
    mounted: function() {
    
        // ...
    
    }
});

License

This package is licensed under the MIT License.

Copyright 2018 Sukohi Kuhoh