A toast plugin for vue2.
Use npm to download code:
npm install kefong/vue-toast
then import it into your project, add below code into your main.js
:
import vueToast from 'vue-toast'
Vue.use(vueToast)
<template>
<div class="toast">
<button v-on:click="$toast.success('Success!!')">Success</button>
<button v-on:click="$toast.error('Error!!')">Error</button>
<div></div>
</div>
</template>
<script>
export default {
name: 'toast',
data () {
return {
}
},
created: function(){
this.$toast.success('Success!!');
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
Prop | Description | Type | Default |
---|---|---|---|
message | String | ||
delay | 自动隐藏需等待多少毫秒 | Number | 3000 |
type | success/error | String | 'success' |