[Vuejs]-How to call a Vue method from main.js in Vue.js file

0👍

If you really want to add a “global” method to your VueJs app you can add it to Vue itself like this:

import {logEngagement} from "./helpers/logEngagement"
Vue.prototype.$logEngagement = logEngagement;

you can use it in component.vue like this:

<script>
  export default {
    mounted() {
      this.$logEngagement.log("this");
    }
  }
<script>

Leave a comment