[Vuejs]-Vue-izitoast function return value

0👍

You must use an Arrow Function to get local scope. Try this:

<template>
  <div id="app">
    <div>
      <button @click="test">TEST</button>
    </div>
    <router-view />
  </div>
</template>

<script>
export default {
  name: 'App',
  methods: {
    test() {
      this.$toast.show('Welcome!', 'Hey', {
        position: 'topCenter',
        buttons: [
          [
            '<button>Change Router</button>',
            (instance, toast) => {
              this.$router.push({ name: 'About' });
            },
            true,
          ],
        ],
      });
    },
  },
};
</script>

Leave a comment