[vuejs] loading-spinner

1412 단어 vuejsvuejs

출처 :: https://www.npmjs.com/package/vue-loading-overlay
데모 :: https://ankurk91.github.io/vue-loading-overlay/
설치 :: npm install vue-loading-overlay@^5.0

  • As plugin
    Install the plugin in your app
import {createApp} from 'vue';
import VueLoading from 'vue-loading-overlay';
import 'vue-loading-overlay/dist/vue-loading.css';
// Your app initialization logic goes here
const app = createApp({});
app.use(VueLoading);
app.mount('#app');
  • with Composition API

    setup() {
           const $loading = useLoading()
           // or use inject without importing useLoading
           // const $loading =  inject('$loading')
    
           const fullPage = ref(false)
    
           const submit = () => {
               const loader = $loading.show({
                   // Optional parameters
               });
               // simulate AJAX
               setTimeout(() => {
                   loader.hide()
               }, 5000)
           }
    
           const onCancel = () => console.log('User cancelled the loader.')
    
           return {
               fullPage,
               submit,
               onCancel
           }
       }

좋은 웹페이지 즐겨찾기