npm i -S @champyin/toast
In main.js of a Vue Project:
import toast from '@champyin/toast';
Vue.use(toast);In any Vue component, you can simply use this.$toast() to popup a tip:
<script>
export default {
mounted() {
this.$toast({
type: 'success',
msg: 'Bravo!'
});
}
}
</script>string
Default value is success.
Type of toast, could be one of these values: success | warning | danger | loading.
string
The info you want to show on the toast. (should be short)
number
Default value is 3.
How many seconds he toast should be shown, after that it could disapear automaticly.
Specially, you can set a value of -1, which means showing the toast forever.
string
Default value is top-center.
Position of toast, could be one of these values: top-left | top-center | top-right | bottom-left | bottom-center | bottom-right | center-center.
boolean
Default value is false.
Determines the toast appears in a full-with way or not.
this.$toast({
type: 'warning',
msg: 'Caution!',
duration: 6,
position: 'top-center',
fullWith: false
});