vue进入页面加载数据缓慢实现loading提示过程

目录
  • 进入页面加载数据缓慢实现loading提示
    • 参数列表说明如下(详细可以观看elementUI官网)
  • vue中加载loading问题
    • 1.loading.vue组件内容如下
    • 2.app.vue中设置
    • 3.在main.js中设置
    • 4.在.vue组件中使用

进入页面加载数据缓慢实现loading提示

比如进入一个页面数据加载缓慢的页面后,等待后端返回数据显示在页面时给个loading的样式

像下面这样:

代码实现如下:

 getStudent() {
      // 开始加载
      let loading = this.$loading({
        lock: true,//lock的修改符--默认是false
        text: "拼命加载中,请稍候...",//显示在加载图标下方的加载文案
        background: "rgba(0,0,0,0.8)",//遮罩层颜色
        spinner: "el-icon-loading",//自定义加载图标类名
      });
      getStudent().then(res => {
        if (res.code === 200) {
          this.user = res.data;
          // 获取数据显示成功后,关闭loading
          loading.close();
        } else {
          this.$message.error("错误!");
        }
      });
    }

参数列表说明如下(详细可以观看elementUI官网)

参数 说明 类型 默认值
target Loading 需要覆盖的 DOM 节点。可传入一个 DOM 对象或字符串;若传入字符串,则会将其作为参数传入 document.querySelector以获取到对应 DOM 节点 object/string document.body
body 同 v-loading 指令中的 body 修饰符 boolean false
fullscreen 同 v-loading 指令中的 fullscreen 修饰符 boolean true
lock 同 v-loading 指令中的 lock 修饰符 boolean false
text 显示在加载图标下方的加载文案 string
spinner 自定义加载图标类名 string
background 自定义加载图标类名 string
customClass 自定义加载图标类名 string

vue中加载loading问题

首先在components文件夹中新建一个loading.vue组件:

1.loading.vue组件内容如下

<template>
  <div class="markbox" v-show="loading" style="background-color: rgba(0, 0, 0, 0.5);">
    <div class="sun-loading"></div>
  </div>
</template>
<script>
export default {
    name: 'loading',
    data() {
        return {
            loading: false
        }
    },
    created() {
        var that = this;
        this.bus.$on('loading', function(data) {
            that.loading = !!data;
        })
    }
}
</script>

css代码:

/*loading开始*/
.sun-loading {
	width: 45px;
	height: 45px;
	display: block;
	animation: sunLoading 1s steps(12, end) infinite;
	background: transparent 	url('data:image/gif;base64,R0lGODlhQABAAKUA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wakQIHMiWxQD2UTNEBaImPIQB9uU6nQIIsqBCERXUp7EQAIBQ76/MNTtqvy3ER9/JQnBg3wKxnrECgfPRLETJMxuBcX3KsoPBtaPedHDQRWAwMAly+iKiqA4cISLTRQQwsM+cEDAwzkcM3fMRHbhMYNSLSFAxElePfQTI9enIh7UVjsy2yU6AUCEJOW/BAQoPVCAb0G4fgYEKDywAc49CyFw442C0zcK9kIcB93wsV67FCJlK+EwQADtUOWFJRjZRTUdLT3ZvQmJwaW9RWTRZNHZYV2lSM0dVdlpsZUxtWU5rbkt4aVAvY1QwekJNNTZaY2tKWDZOaURM');
	background-size: 100%;
    margin:auto;
    position:absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right:0;
}
/*loading结束*/	

2.app.vue中设置

<template>
  <div id="app">
    <router-view/>
    <loading></loading>
  </div>
</template>
<script>
    import loading from '@/components/common/loading'
    export default {
      name: 'App',
      components:{loading}
    }
</script>

3.在main.js中设置

Vue.prototype.bus = new Vue;

4.在.vue组件中使用

 // 显示loading
this.bus.$emit('loading', true);

// 关闭loading
this.bus.$emit('loading', false);

效果如下:

以上为个人经验,希望能给大家一个参考,也希望大家多多支持我们。

(0)

相关推荐

  • vue 项目中使用Loading组件的示例代码

    什么是vue插件? 从功能上说,插件是为Vue添加全局功能的一种机制,比如给Vue添加一个全局组件,全局指令等: 从代码结构上说,插件就是一个必须拥有install方法的对象,这个方法的接收的第一个参数是Vue构造函数,还可以接收一个可选的参数,用于配置插件: var myplugin = { install:function(Vue, options){ ... } } 从意义上来说,正如jQuery的$.fn使jQuery有了一个庞大的生态一样,Vue的插件机制使Vue形成了一个生态系统,你

  • vue实现图片加载完成前的loading组件方法

    如下所示: <template> <img :src="url"> </template> <script> export default { props: ['src'], // 父组件传过来所需的url data() { return { url: 'http://www.86y.org/images/loading.gif' // 先加载loading.gif } }, mounted() { var newImg = new Im

  • vue 全局封装loading加载教程(全局监听)

    前言: 为了页面美观,请求接口的时候延迟没有数据,页面感觉狠卡顿,封装loading,请求接口成功后隐藏掉(我这是用的vant 组件根据自己情况进行改变). 第一步: 建立loading.vue <template> <div class="loading"> <van-loading size="36px" vertical>加载中...</van-loading> </div> </templat

  • vue前端页面数据加载添加loading效果的实现

    目录 前端页面数据加载添加loading效果 具体实现 全局loading配置 1 再src/componennts/Spinner下面建立一个index.vue 2 再utils下面tools.js 3 再utils下面建议一个request.js 封装的axios请求 4 修改app.vue 前端页面数据加载添加loading效果 在前端上传文件或者加载数据的时候会有一段等待时间,如果加上一个loading效果会减轻用户等待的枯燥,这里就来记录学习一下如何实现loading效果. 效果大致如

  • vue进入页面加载数据缓慢实现loading提示过程

    目录 进入页面加载数据缓慢实现loading提示 参数列表说明如下(详细可以观看elementUI官网) vue中加载loading问题 1.loading.vue组件内容如下 2.app.vue中设置 3.在main.js中设置 4.在.vue组件中使用 进入页面加载数据缓慢实现loading提示 比如进入一个页面数据加载缓慢的页面后,等待后端返回数据显示在页面时给个loading的样式 像下面这样: 代码实现如下: getStudent() { // 开始加载 let loading = t

  • vue.js页面加载执行created,mounted的先后顺序说明

    created页面加载未渲染html之前执行. mounted渲染html后再执行. 由于created在html模板生产之前所以无法对Dom进行操作而mounted可以. 补充知识:关于Vue子组件data选项某个属性引用子组件props定义的属性的几点思考 学过Vue的都知道Vue等MVVM框架相对于传统的JS库比如Jquery最大的区别在于数据驱动视图,重点在于数据,拿到数据后将数据通过模板{{}}语法或者v-html展示在页面上. 我们也都知道在Vue父子组件可以通过Props实现父组件

  • vue 防止页面加载时看到花括号的解决操作

    如下所示: <style> [v-cloak]{ display:none } </style> v-cloak v-text v-html v-cloak用于大段 v-text用于单个标签 v-html用于带有标签的处理 补充知识:vue花括号数据绑定不成功的问题 我就废话不多说了,大家还是直接看案例吧~ <!DOCTYPE html> <html> <head> <meta charset="utf-8" />

  • vue实现页面加载动画效果

    我们经常看到数据未出现时,页面中会有一条提示消息, 页面正在加载中,如何实现该效果呢 ,请看下面代码 <template> <section class="page" v-if="option" :style="{background: option.background,color: option.color||'#fff'}" :class="{'page-before': option.index < cu

  • ajax请求+vue.js渲染+页面加载的示例

    1.导入js <script type="text/javascript" src="<c:url value="/resources/lib/jquery/jquery-1.11.0.min.js" />"></script> <!--标准mui.css--> <link href="<c:url value=" rel="external nofollo

  • Ajax 加载数据 练习代码

    前端与js代码 <h1>显示数据</h1> <table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td>代号</td> <td>姓名</td> <td>性别</td> <td>民族</td> <

  • Vue下滚动到页面底部无限加载数据的示例代码

    看到一篇Implementing an Infinite Scroll with Vue.js, 觉得挺实用的就看了下, 顺便简单翻译了一下给需要的人参考. 从这个项目中可以加深对Vue的生命周期的理解, 何时开始axios请求, 如何结合Vue使用原生js来写scroll事件等等, 我这里主要是对原文的重点提取和补充 本文技术要点 Vue生命周期 axios简单用法 moment.js格式化日期 图片懒加载 结合原生js来写scroll事件 请求节流 创建项目 首先创建一个简单的vue项目 #

  • vue打包chunk-vendors.js文件过大导致页面加载缓慢的解决

    目录 打包chunk-vendors.js过大导致页面加载缓慢 1.chunk-vendors.js 简介 3.chunk-vendors.js 文件大小分析 3.方式一 4.其他方式 chunk-vendors过大导致首屏加载太慢的优化 1.安装compression-webpack-plugin插件 2.接下来要去修改vue的配置文件 vue.config.js 3.nginx配置 打包chunk-vendors.js过大导致页面加载缓慢 1.chunk-vendors.js 简介 顾名思义

  • Vue实现让页面加载时请求后台接口数据

    目录 让页面加载时请求后台接口数据 Vue请求后台数据几种方式 1.vue-resource官方提供的vue的一个插件 2.axios的使用 3.fetch-jsonp不受跨域限制 让页面加载时请求后台接口数据 <template>   <div class="hello">     <div>       {{title}}     </div>     <hr>     <button @click="co

随机推荐