iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
📖

Loading Spinner | Vue3 (Options API)

に公開

Overview

This is the spinning indicator displayed when the screen loads. I use it often, so here's a note.

Code

LoadingSpinner.vue
<template>
    <div class="loading-spinner">
        <div class="spinner"></div>
        <p v-if="m">{{ m }}</p>
    </div>
</template>

<script>
export default {
    name: 'LoadingSpinner',
    props: {
        m: {
            type: String,
            default: null,
        },
    },
}
</script>

<style lang="scss" scoped>
.loading-spinner {
    .spinner {
        margin: 2rem auto;
        border: 4px solid #f3f3f3;
        border-top: 4px solid rgb(255, 52, 52);
        border-radius: 50%;
        width: 40px;
        height: 40px;
        animation: spin 1s linear infinite;
    }
    p {
		text-align: center;
	}
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    
    100% {
        transform: rotate(360deg);
    }
}
</style>

Discussion