VueJS Mixins 方法直接调用 [英] VueJS Mixins Methods Direct Call
本文介绍了VueJS Mixins 方法直接调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在 VueJS 上测试 Mixin,我有一个问题.有没有办法直接从 Mixins 调用事件而不必在我的 methods
中分配它?
I'm testing Mixins on VueJS and I have a question. Is there a way to call an event directly from a Mixins without having to assign it in my methods
?
MyMixins.js
import Vue from 'vue'
Vue.mixin({
methods: {
Alerta(){
alert('WORK!')
}
}
})
app.vue
<template>
<button v-on:click="AlertaInterno">test</button>
</template>
<script>
export default{
methods:{
AlertaInterno(){
this.Alerta()
}
}
}
</script>
<块引用>
上面的代码有效.我想知道如何直接调用 mixin 函数,如下所示:
app.vue
app.vue
谢谢!
推荐答案
可以,直接调用即可.mixin 中的方法与它们混合"在一起的 Vue 或组件合并.它们可以像任何其他方法一样被调用.
解决方案
这篇关于VueJS Mixins 方法直接调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文