前提:确保已经下载好了 vant 插件git
在须要使用的页面引入github
import Vue from 'vue' import {Toast} from 'vant'
加载该中间件web
Vue.use(Toast)
在 created 钩子函数内直接使用vuex
const toast = Toast.loading({ message: '加载中...', //加载的时候显示的文字 duration:0, //展现时长(ms),值为 0 时,toast 不会消失 overlay:true, //是否显示遮罩层 forbidClick: true //是否禁止背景点击 });
在达到某种条件(数据加载完毕后)再调用方法关闭便可缓存
if(this.cinemaList.length > 0 ){ // console.log("直接使用缓存vuex的数据...") toast.clear() }else{ this.getCinemaActions(this.cityId).then(res=>{ toast.clear() }) }