【发布时间】:2021-12-07 21:59:01
【问题描述】:
我必须调用带有参数的函数,但我没有找到解决问题的正确方法。 NavigateTo 应该将一个字符串值传递给我的索引以切换它并导航到正确的组件(无 vue 路由器)。
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>
【问题讨论】:
标签: javascript function vue.js function-parameter