LoadingExample.vue 728 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <template>
  2. <h1>加载中</h1>
  3. <button class="btn btn-default" @click="start">开始</button>
  4. <button class="btn btn-default" @click="startAndStop">定时关闭</button>
  5. <button class="btn btn-default" @click="start2">打开2个loading</button>
  6. <Loading v-if="loading" />
  7. </template>
  8. <script>
  9. import Loading from '@/loading/index.js';
  10. export default {
  11. components: {
  12. Loading,
  13. },
  14. data: function () {
  15. return {
  16. loading: false,
  17. };
  18. },
  19. methods: {
  20. start: function(){
  21. this.loading = true;
  22. },
  23. startAndStop: function(){
  24. this.loading = true;
  25. let _self = this;
  26. window.setTimeout(function(){
  27. _self.loading = false;
  28. }, 5000);
  29. },
  30. },
  31. };
  32. </script>