mardi 1 août 2017

Javascript function in laravel not defined

I added an js method to my app.js:

require('./bootstrap');

window.Vue = require('vue');

Vue.component('example', require('./components/Example.vue'));

const app = new Vue({
    el: '#app'
});

function hello()
{
    alert("hello");
}

Then compiled my assets and added app.js to my view:

<script src=""></script>

If i load my view at this point and look at the source i can see the link to app.js and if i open that app.js i can see my hello method in there with a lot of other stuff.

Now when i want to call my method i try to do it like this:

<a onclick="hello();">

But in my console i get an Uncaught ReferenceError: hello is not defined error. What could be the problem?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire