基于weuil oading插件封装

Posted qiezuimh

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于weuil oading插件封装相关的知识,希望对你有一定的参考价值。

 

<!-- Loading.vue -->
<template>
  <div id="loadingToast" v-if="show">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast">
      <i class="weui-loading weui-icon_toast"></i>
      <p class="weui-toast__content" v-if="text">text</p>
    </div>
  </div>
</template>

<script>
export default 
  props: 
    text: 
      type: String,
      default: ‘‘
    ,
    show: Boolean
  
;
</script>
    
<style>
</style>
    
// loading.js
import LoadingComponent from ‘./Loading.vue‘

let $vm

export default 
  install(Vue, options) 
    if (!$vm) 
      const LoadingPlugin = Vue.extend(LoadingComponent);

      $vm = new LoadingPlugin(
        el: document.createElement(‘div‘)
      );

      document.body.appendChild($vm.$el);
    

    $vm.show = false;

    let loading = 
      show(text) 
        $vm.show = true;
        $vm.text = text;
      ,
      hide() 
        $vm.show = false;
      
    ;

    if (!Vue.$loading) 
      Vue.$loading = loading;
    

    Vue.mixin(
      created() 
        this.$loading = Vue.$loading;
      
    )
  

 

// main.js

import Loading from ‘views/common/baseui/loading‘
Vue.use(Loading);

 

 

调用: 

  mounted () 
    this.$loading.show();
    let _ = this
    setTimeout(() => 
       _.$loading.hide();
     , 5000)
   ,

 

以上是关于基于weuil oading插件封装的主要内容,如果未能解决你的问题,请参考以下文章

JQuery分页插件封装(源码来自百度,自己封装)

简易的highcharts公共绘图模块封装--基于.net mvc

用js面向对象思想封装插件

基于jquery的带事件显示功能的日历板插件calendar.js

OADMacros是啥

用于封装通用数据源的接口定义[关闭]