[Vuejs]-Make callback in Vue

0👍

Okay I figured it out.

index.html

<script>
function vueWidget_onInitCallback () {
  console.log('plugin initiated');
}
</script>

App.vue

methods: {
  someFunction() {
    function onInit(callback) {
      if (callback && typeof(callback) == "function") callback();
    }
    onInit(vueWidget_onInitCallback);
  },
},
mounted() {
  this.someFunction()
}

Everything works just fine.

Leave a comment