Element 中使用加载动画

阅读 76

2023-02-09


<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>

精彩评论(0)

0 0 举报