<script>
//映射vuex中控制loading显示隐藏的状态到此组件
import { mapState } from "vuex";
export default {
  data() {
    return {
      show: false,
    };
  },
  computed: {
    ...mapState(["loadingState"]),
  },
  watch: {
    // 监听vuex中的loadingState变化
    loadingState(newVal, oldVal) {
      if (newVal) {
        this.open();
      } else {
        this.close();
      }
      // console.log(newVal, oldVal, "监听到loadingState变化");
    },
  },
  methods: {
    open() {
      this.show = true;
    },
    close() {
      this.show = false;
    },
  },
};
</script>
<script>
	//显示加载框
	uni.showLoading({
	    title: '加载中'
	});
	 
	​
</script>

<style>
</style>