版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38543537/article/details/88090135
最近用Vux写项目的时候用到Vux中的Loading组件,一开始按照官网给的方法引入使用,结果报错如下:
几经查找原来是需要在main.js中引入如下组件:
import { LoadingPlugin } from 'vux'
Vue.use(LoadingPlugin)
然后既可以正常使用了:
Loading另外一种用法,此方法无需在main.js中引入LoadingPlugin也可使用:
1、模板编写
<div v-transfer-dom>
<loading :show="show2" text="Loading"></loading>
</div>
<x-button @click.native="showLoading" type="primary">显示loading (2s后关闭)</x-button>
2、在data里边定义—show2: false,
3、在methods里边写入如下方法:
showLoading () {
this.show1 = true; //显示Loading
setTimeout(() => {
this.show1 = false; //2秒后隐藏Loading
}, 2000)
},