npm install vuex-isloading
- use isLoading in Vuex's plugins
import Vuex from 'vuex'
import isloading, { next, is } from '../src'
const router = new Vuex({
...
plugins: [
isloading
]
})
import isloading, { next, is } from '../src'
const store = {
state: {},
getters: {
$is: is
}
}
import isloading, { next, is } from '../src'
const store = {
state: {},
actions: {
testES6 () {
$http.get('www.github.com')
.then(() => {
next.apply(this, arguments)
})
},
testES5 () {
const _this = this
const _arg = arguments
$http.get('www.github.com')
.then(function () {
next.apply(_this, _arg)
})
}
}
}
{{ $store.getters.$is.anyLoading() }}
{{ $store.getters.$is.loading('testES5') }}
{{ $store.getters.$is.loading(['testES5', 'testES6']) }}
{{ $store.getters.$is.loadings() }}