1.1.4 • Published 4 years ago

vue-loading-new v1.1.4

Weekly downloads
15
License
ISC
Repository
-
Last release
4 years ago

vue-loading-new

Just another collection of loading spinners with Vue.js

Installation

npm install --save vue-loading-new

or

yarn add vue-loading-new

Usage

在页面引用

在App.vue 面页中引用CSS 
<style>
@import "~vue-loading-new/dist/vueLoadingNew.css";
</style>

<script>
  import loading from 'vue-loading-new';
  export default {
    data() {
      return {
        loads:null
      }
    },
    methods: {
      open(){
        this.loads=loading();
        setTimeout(() => {
          this.loads.close()
        }, 300);
      }
    }
  }
</script>

或 全局mixins中使用 
data() {
    return {
      loadingInstance: null,
      spinner: {
        show: res => {
          if (this.loadingInstance) {
            this.loadingInstance.close();
          }
          let options = {
            lock: true,
            target: null,
            text: '',
            type: 4,
            background: 'rgba(255, 255, 255, 0.6)',
            customClass: ''
          }
          Object.assign(options, res);
          this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
            this.loadingInstance = Loading(options);
          });
        },
        close: res => {
          this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
            if (this.loadingInstance) {
              this.loadingInstance.close();
            }
          });
        }
      }
    }
  },

  在页面中 使用 this.spinner.show() this.spinner.close();

配置

let config={
  text: "",
  type: 1,
  color: [],
  html: "",
  background: null,
  fullscreen: true,
  visible: true,
  customClass: '',
}

this.loads=loading(config);

切换图标 this.loads=loading({type:2});

html结合customClass,可打造自己的动态图片

Props

nameDescriptiontypedefault
isLoading是否显示Booleanfalse
type加载动态图Int1
text文字显示String加载中...
color图标颜色array
background背景设置Stringtransparent
customClass自定样试String
fullscreenbooleanture
htmlv-htmlStringhtml

github:https://github.com/wyulang/vue-loading-spinners