I've to call a function with parametres but i didn't find a correct solution for my problem. The NavigateTo should pass a String value to my index to switch it and navigate to the correct component(no vue router).
Home.js
Vue.component('Home', {
props: ['visible','logged'],
data: function (){
return{
}
},
template: <a class="btn btn-primary display-4" on:click="NavigateTo(accedi)">Accedi</a>\n'
(only the button that call the function,i will post the rest of the code only if necessary)
methods:{
NavigateTo:function(destination){
this.$emit('transit-inner', destination);
}
}
});
Index.js
<section id="Home" style="margin-top: 60px">
<Home v-bind:visible="visible" v-bind:logged="session_info" v-on:transit-inner="goto()"></Home>
<script>
new Vue({
el: '#Home',
data:{
visible: routes.visible_home,
session_info: routes.status_session
},
methods:{
goto: function (destination){
alert(destination);
}
}
})
</script>
</section>
CodePudding user response:
You're using an Inline Event Handler (goto()
) in your template:
<Home v-bind:visible="visible" v-bind:logged="session_info" v-on:transit-inner="goto()"></Home>
You've two options:
One, remove the ()
<Home v-bind:visible="visible" v-bind:logged="session_info" v-on:transit-inner="goto"></Home>
Or, provide the $event
special variable if using Inline Handler
<Home v-bind:visible="visible" v-bind:logged="session_info" v-on:transit-inner="goto($event)"></Home>