Reputation: 4525
In a Laravel blade template I can access some data using @{{list.length}}.
<template id="events-template">
@{{list.length}}
</template>
How do I use this within a javascript function within the same view template?
Vue is defined in app.js as
var vm = new Vue({
el: 'body',
});
app.js is called before the script in my view template
Upvotes: 1
Views: 570
Reputation: 12339
First, be sure that you actually have defined the list
var in your vue instance
data: {
list: []
}
Then, to access the list var, use the instance scope, for example in some method
methods: {
someMethod: function () {
console.log(list) // undefined
console.log(this.list) // []
}
}
Upvotes: 2