I just try to use the composition in Nuxt.
And i just wonder that, is that $loading.start() and finish() is available inside setup() ?
I searched in documentation and cannot found it, and i've tried using context property, but still can't find the helper function of $loading.
use wrapProperty
import { defineComponent, wrapProperty } from '@nuxtjs/composition-api'
export const useNuxt = wrapProperty('$nuxt', false)
export default defineComponent({
const { $loading } = useNuxt()
try {
$loading.start()
/* balabalabalabala */
} catch (err) {
console.error(err)
} finally {
$loading.finish()
}
})
thank you @mao-shonen, it worked like a charm.
Most helpful comment
use wrapProperty