欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

uniapp使用v-loading并且不引入element-ui的操作方法

 更新時間:2022年10月19日 10:34:07   作者:zaijinyang  
這篇文章主要介紹了uniapp使用v-loading并且不引入element-ui,首先創(chuàng)建loading.js,創(chuàng)建lloading.scss,本文結(jié)合示例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

1、創(chuàng)建loading.js

import Vue from 'vue';
/**
 * 插入loading
 */
const insertDom = (el) => {
  let dom = `<div class="el-loading-mask">
        <div class="el-loading-spinner">
          <svg viewBox="25 25 50 50" class="circular">
            <circle cx="50" cy="50" r="20" fill="none" class="path"> </circle>
          </svg>
          <p class="el-loading-text">拼命加載中...</p>
        </div>
      </div>`;

  //el添加相對定位
  el.classList.add('el-loading-parent--relative');

  // 插入到被綁定的元素內(nèi)部
  el.insertAdjacentHTML('afterbegin', dom);
};

/**
 * 移除loading
 */
const removeDom = (el) => {
  const ds = el.getElementsByClassName('el-loading-mask')[0];
  if (ds) {
    el.removeChild(ds);
    el.classList.remove('el-loading-parent--relative');
  }
};

// 更新是否顯示
const toggleLoading = (el, binding) => {
  if (binding.value) {
    insertDom(el);
  } else {
    removeDom(el);
  }
};

Vue.directive('loading', {
  bind: function (el, binding, vnode) {
    toggleLoading(el, binding);
  },
  //所在組件的 VNode 更新時調(diào)用--比較更新前后的值
  update: function (el, binding) {
    if (binding.oldValue !== binding.value) {
      toggleLoading(el, binding);
    }
  }
});

2、創(chuàng)建lloading.scss

/deep/ .el-loading-parent--relative {
  position: relative !important;
}

/deep/ .el-loading-mask {
  position: absolute;
  z-index: 2000;
  background-color: rgba(0, 0, 0, 0.8);
  margin: 0;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  transition: opacity 0.3s;

  .el-loading-spinner {
    top: 50%;
    margin-top: -21px;
    width: 100%;
    text-align: center;
    position: absolute;
  }

  .el-loading-spinner .el-loading-text {
    color: #409eff;
    margin: 3px 0;
    font-size: 14px;
  }

  .el-loading-spinner .circular {
    height: 42px;
    width: 42px;
    animation: loading-rotate 2s linear infinite;
  }

  .el-loading-spinner .path {
    animation: loading-dash 1.5s ease-in-out infinite;
    stroke-dasharray: 90, 150;
    stroke-dashoffset: 0;
    stroke-width: 2;
    stroke: #409eff;
    stroke-linecap: round;
  }

  .el-loading-spinner i {
    color: #409eff;
  }

  .el-loading-fade-enter,
  .el-loading-fade-leave-active {
    opacity: 0;
  }

  @keyframes loading-rotate {
    to {
      transform: rotate(1turn);
    }
  }

  @keyframes loading-dash {
    0% {
      stroke-dasharray: 1, 200;
      stroke-dashoffset: 0;
    }

    50% {
      stroke-dasharray: 90, 150;
      stroke-dashoffset: -40px;
    }

    to {
      stroke-dasharray: 90, 150;
      stroke-dashoffset: -120px;
    }
  }
}

3、將scss引入通用樣式(一般在uni.scss中引入)

@import '/static/css/loading.scss';

4、在main.js中引入loading.scss

// 使用v-loading
import Loading from '@/utils/loading.js'
Vue.use(Loading)

5、頁面上使用

<view class="details-video" v-loading="loading"></view>

6、效果:

到此這篇關于uniapp使用v-loading并且不引入element-ui的文章就介紹到這了,更多相關uniapp使用v-loading內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • vue引用BootStrap以及引用bootStrap-vue.js問題

    vue引用BootStrap以及引用bootStrap-vue.js問題

    這篇文章主要介紹了vue引用BootStrap以及引用bootStrap-vue.js問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-10-10
  • Vue3中嵌套路由和編程式路由的實現(xiàn)

    Vue3中嵌套路由和編程式路由的實現(xiàn)

    Vue?Router在Vue.js的核心庫上提供了路由的功能,使得我們可以在單頁應用中實現(xiàn)頁面的切換、跳轉(zhuǎn)和參數(shù)傳遞等功能,本文主要介紹了Vue3中嵌套路由和編程式路由的實現(xiàn),感興趣的可以了解一下
    2023-12-12
  • vue表格(table)計算總計方式

    vue表格(table)計算總計方式

    這篇文章主要介紹了vue表格(table)計算總計方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-07-07
  • vue實現(xiàn)城市列表選擇功能

    vue實現(xiàn)城市列表選擇功能

    這篇文章主要介紹了vue實現(xiàn)城市列表選擇功能,本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下
    2018-07-07
  • vue中的可拖拽寬度div的實現(xiàn)示例

    vue中的可拖拽寬度div的實現(xiàn)示例

    本文主要介紹了vue中的可拖拽寬度div的實現(xiàn)示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2022-04-04
  • 解決ant-design-vue中menu菜單無法默認展開的問題

    解決ant-design-vue中menu菜單無法默認展開的問題

    這篇文章主要介紹了解決ant-design-vue中menu菜單無法默認展開的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-10-10
  • vue ajax 攔截原理與實現(xiàn)方法示例

    vue ajax 攔截原理與實現(xiàn)方法示例

    這篇文章主要介紹了vue ajax 攔截原理與實現(xiàn)方法,結(jié)合實例形式分析了vue.js基于ajax攔截實現(xiàn)無刷新登錄的相關原理與操作技巧,需要的朋友可以參考下
    2019-11-11
  • vue微信分享的實現(xiàn)(在當前頁面分享其他頁面)

    vue微信分享的實現(xiàn)(在當前頁面分享其他頁面)

    這篇文章主要介紹了vue微信分享,在當前頁面分享其他頁面,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-04-04
  • Vue使用Post進行表單提交

    Vue使用Post進行表單提交

    這篇文章主要介紹了Vue使用Post進行表單提交,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-06-06
  • vue組件 $children,$refs,$parent的使用詳解

    vue組件 $children,$refs,$parent的使用詳解

    本篇文章主要介紹了vue組件 $children,$refs,$parent的使用詳解,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-07-07

最新評論