[Vuejs]-Updating bootstrap-vue alert's content

0👍

It’s just like updating any other reactive property. The example below shows three states… default, loading and updated.

<template>
  <div id="app">
    <b-alert show>{{ alertText }}</b-alert>
    <b-btn @click="updateText">Update Text</b-btn>
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      alertText: 'Default text',
    }
  },
  methods: {
    updateText() {
      this.alertText = 'loading'
      setTimeout(() => {
        this.alertText = Math.random()
      }, 2000)
    },
  }
}
</script>

Leave a comment