Tommy001
6 months ago

How to pass a js variable into a Vue.js instance?

Posted 6 months ago by Tommy001

In my blade template I have a javascript snippet that produces a variable that holds an index, to be used in an array. I would like to use that index in a Vue instance, like this:

    var app = new Vue({
        el: '#root',
        data: {
            url: "{{route('showphoto')}}/{{$photos[nextIndex]->id}}"
        }
    });

So, how can I pass the JS variable nextIndex into the vue data above?

Please sign in or create an account to participate in this conversation.