Loading 全局加载 - 图1

引用组件

  1. import { Loading } from 'genie-ui'
  2. // 开始全局加载
  3. Loading.open()
  4. // 关闭全局加载
  5. Loading.close()

也可以使用插件方式加载

  1. Vue.use(Loading)
  2. Vue.extend({
  3. methods: {
  4. xxx: {
  5. this.$loading.open()
  6. }
  7. }
  8. })

Event

事件名称 说明 回调参数
open (options) 打开全局 Loading 状态
close 关闭全局 Loading 状态
  • text 加载时,提示的文案
  • duration 自动关闭全局 Loading 时间,默认值 0 表示不关闭

使用示例

  1. <template>
  2. <div>
  3. <button @click="showLoading">点击显示 Loading</button>
  4. </div>
  5. </template>
  6. <script>
  7. import { Loading } from 'genie-ui'
  8. export default {
  9. components: {
  10. },
  11. methods: {
  12. showLoading (v) {
  13. console.log('opening')
  14. Loading.open({
  15. text: '加载中...', // 可选
  16. // NOTE: 可以使用 duration 定时关闭,也可以调用 close 手动关闭
  17. // duration: 5000
  18. })
  19. setTimeout(function () {
  20. console.log('closing')
  21. Loading.close()
  22. }, 5000)
  23. }
  24. }
  25. }
  26. </script>