1.0.8 • Published 5 years ago

vue2-toast-plugin v1.0.8

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

vue2-toast-plugin

A simple toast plugin for vue2.

Usage

Use vue-cli

Install:

npm install vue2-toast-plugin --save

Import:

import Toast from "vue2-toast-plugin";
import "vue2-toast-plugin/dist/style.css";

Vue.use(Toast);

Direct <script> include

It expose the global variable:

Vue.use(VueToast)

You can set the configuration:

Vue.use(Toast, {
    position: 'center',
    duration: 3000,
    wordWrap: true,
    width: '100px'
});

In the component:

export default {
    methods:{
        openCenter(){
            this.$toast('hello');
        },
        openTop(){
            this.$toast('hello', {
                position: 'top',
                duration: 2000
            });
        },
        openWithIcon(){
            this.$toast('hello', {
                position: 'top',
                duration: 2000,
                icon: 'success' //or error
            });
        },
        openWithCallback(){
            this.$toast("hello", function(){
                console.log("done");
            });
        },
        openWithCallback2(){
            this.$toast("hello", {
                position: 'top',
                duration: 2000,
                icon: 'success'
            }, function(){
                console.log("done");
            });
        },
        loading(){
            this.$loading('getting data...');
            let t = this;
            setTimeout(function () {
              t.$loading.close();
            }, 2000)
        }
    }
}

options

Vue.use(Toast, [options])
keytypevaluedefault
positionstring"top" Ι "center" Ι "bottom""center"
durationnumber20002000
wordWrapbooleantrue Ι falsefalse
widthstring"100px""auto"
1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago