Skip to content

kefong/vue-toast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vue-toast

A toast plugin for vue2.

Install

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)

Usage

<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>

Props

Prop Description Type Default
message String
delay 自动隐藏需等待多少毫秒 Number 3000
type success/error String 'success'

Demo

demo

Screenshot