Toast提示
使用方式(Usage)
安装(Install)
npm install optimat-vue-toast -save
导入(Import)
*.js
;
*.vue
<script> import ToastLayout from 'optimat-vue-toast' import {mapActions, mapGetters} from 'vuex'; { methods: { ...mapActions(['showToast']), action () { this.showToast('content' || {content:'message', duration:1000}); } } }</script>
标签(Target)
*vue
引入Vuex(Use Vuex)
actions.js
const showToast = { ;};const hideToast = { ;};
getters.js
const toastOptions = statetoastOptions;
index.js
;;;;Vue;const TOAST_DEFAULT_OPTIONS = isShow: false content: '请稍等...' duration: 1000;let state = toastOptions: TOAST_DEFAULT_OPTIONS;let mutations = { let defaultOptions; if typeof options === 'string' defaultOptions = ; defaultOptionscontent = options; else defaultOptions = ; defaultOptionsisShow = true; statetoastOptions = defaultOptions; } { statetoastOptions = TOAST_DEFAULT_OPTIONS; }; Vuex;// clone 方法请查看 optimat-vue-utils 中的 ObjectSupport 工具
Options | Type | Description | Default |
---|---|---|---|
content | string | 显示内容 | 60000 |
duration | number | 显示时长(ms),为300~60000之间 | 1000 |