0.0.1 • Published 7 years ago

vue-bootalert v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

vue-bootalert

VueJS component for generating Bootstrap alerts

Installation

# install with npm
npm install vue-bootalert --save
var VueBootalert = require('vue-bootalert')
Vue.use(VueBootalert)

Usage

Add as a component:

components: {
    VueBootalert
}

You can then create an alert with:

<bootalert message="Your message here"></bootalert>

You can configure the alert with the following parameters:

NameDescriptionRequiredAllowed ValuesTypeDefault Value
typeThe alert style, taken from Bootstrap alert classesNinfo, warning, success, dangerStringinfo
messageThe message to display in the alertYText/HTMLStringnil
shouldDisappearThe alert should disappear automatically after a period of timeNtrue, falseBooleantrue
displayTimeThe time in miliseconds the message should stay on screen for (if shouldDisappear is set to true)NInteger5000
alertDismissableAllow the user to close the alert by clicking on XNDismissable if presentfalse

Examples

Basic Usage

<bootalert type="danger" message="test message 1 (dismisable)" shouldDisappear="false" alertDismissable></bootalert>
<bootalert type="success" message="test message 2"></bootalert>

Dynamically creating alerts

<bootalert v-for="(alert,index) in alerts" :key="index" v-bind:type="alert.type" v-bind:message="alert.message" v-bind:shouldDisappear="alert.shouldDisappear" alertDismissable></bootalert>
export default {
    data: function() {
      return {
        alerts: []
      }
    },
    methods: {
      createErrorAlert: function(message) {
        this.alerts.push({
          type: 'danger',
          message: message,
          shouldDisappear: false
        });
      }
    }
}

// Then call createErrorAlert when you want a new message
createErrorAlert("Your message here")