[Vuejs]-How to remove vuetify card automatically after a few seconds

0👍

You can’t do it from removeMessage, because you want it to happen without pressing the button.

You should watch for changes on the data.show. Details on how to do this here.

Inside the watch when the value is set to true you can set a timeout and save the identifier returned by setTimeout. The timeout should set data.save to false, this will close the notification. You also need to clear the timeout from inside removeMessage or from inside the watch method when the value becomes false.

You need to clear the timeout when the notification is closed to prevent the following behaviour:

  • a notification is opened
  • the user taps the close button
  • another notification is opened, during the close timeout
  • the timeout fires and the second notification is closed prematurely

Leave a comment