最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue封裝全局的Loading問(wèn)題

 更新時(shí)間:2026年05月24日 10:41:22   作者:想要飛翔的pig  
本文詳細(xì)介紹了在Vue項(xiàng)目中實(shí)現(xiàn)加載動(dòng)畫的方法,通過(guò)在app.vue注入樣式、封裝js文件及在main.js掛載,最后在頁(yè)面調(diào)用觸發(fā)的具體步驟,為開(kāi)發(fā)者提供實(shí)用指南

一、在app.vue組件注入loading樣式

<template>
<meg-loading
    :tip="centitle"
    :indicator="indicator"
    :spinning="antLoading"
    style="background-color: rgba(0, 0, 0, 0.6)"
  >
  </meg-loading>
  </template>
  <script>
  import { mapState } from "vuex";
  export default {
  name: "MegCubeLayout",
    data() {
	 return {
  		indicator: <meg-icon name="megui-loading2"></meg-icon>,
	 };
  },
  computed: {
    ...mapState("megCube/container", ["antLoading", "centitle"]),
  		},
	  };

二、封裝的js文件 globalMethod.js

export const showLoading = function (flag, msg) {
    if (msg) {
      this.$store.state.megCube.container.centitle = msg
    } else {
      this.$store.state.megCube.container.centitle = '加載中...'
    }
    if (flag) {
        this.$store.state.megCube.container.antLoading = flag
    } else {
        this.$store.state.megCube.container.antLoading = false

    }
    
  }

三、在main.js掛載

import { showLoading } from './common/globalMethod'
Vue.prototype.$showLoading = showLoading // 全局loading

四、vue頁(yè)面調(diào)用

  • 觸發(fā):    
this.$showLoading(true, '正在上傳中')
  • 停止:    
this.$showLoading(false)

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

玛纳斯县| 怀集县| 德州市| 灵璧县| 奇台县| 休宁县| 光泽县| 浪卡子县| 喜德县| 平塘县| 宕昌县| 万源市| 广河县| 凤山县| 婺源县| 台东市| 珠海市| 绵阳市| 南昌市| 平遥县| 宜宾市| 济宁市| 甘洛县| 赣榆县| 长子县| 富平县| 收藏| 临邑县| 麻江县| 海阳市| 石门县| 鲁山县| 全南县| 鸡东县| 应用必备| 牡丹江市| 加查县| 华宁县| 玛沁县| 乡宁县| 台江县|