[Vuejs]-Vue Dialog execute whenever activated/called

0👍

You can use the mounted event for the initialization. And you can use the watch for the updates:

The code would be that way:

export default {
  name: 'app',
  data: () => ({
    orderDetailsDialogVisible: false,
  }),
  watch: {
    orderDetailsDialogVisible(newValue, oldValue) {
      if (newValue) {
        this.requestApi();
      }
    },
  },
  methods: {
    requestApi() {
      console.log('requestApi');
      // axios.get...
    },
  },
  mounted() {
    this.requestApi();
  },
};

Leave a comment