Element 中使用加载动画

<script>
// 1.引入动画组件
import { Loading } from 'element-ui';

export default {
    name:"index",
    data() {
        return {
            // 2.定义实例 
            loadingInstance:null,
            list:[]
        };
    },

    methods: {
        getData(){
            // 3. 生成动画
            this.loadingInstance = Loading.service({
                // 动画中的文字
                text:'加载中',
                // 要加载动画的容器
                target:'.app-container'
            });

            this.$http.get('index').then((result) => {
                if(res.code==10000){

                    this.list = result.data;
                    // 4. 请求完成后关闭动画
                    this.loadingInstance.close();
                }
            });

        }

    }
};
</script>

猜你喜欢

转载自blog.csdn.net/weixin_40629244/article/details/113174313
今日推荐