common=》loading.vue
<template>
<div>
<van-overlay :show="true" >
<div class="wrapper" >
<van-loading size="54px" vertical>加载中...</van-loading>
</div>
</van-overlay>
</div>
</template>
<script>
export default {
data() {
return {};
},
mounted() {
console.log(this.$store.state.num)
},
methods: {},
components: {}
};
</script>
<style scoped>
.wrapper {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
.block {
width: 120px;
height: 120px;
background-color: #fff;
}
</style>
App.vue
<template>
<div id="app">
<router-view/>
<Loading v-show="this.$store.state.loading"> </Loading>
</div>
</template>
<script>
import Loading from '@/common/Loading'
export default {
name: 'App',
components: {
Loading
}
}
</script>
store=>index
state:{
loading:true,
},
mutations:{
//设置loading效果
setLoading(state,payload){
state.loading=payload
}