Vue Loading Template
Vue Loading Template (vue-loading-template) is a Vue.js 2 component library offering a collection of SVG-based loading indicators. It provides a straightforward API to embed various animated loaders, such as 'balls', 'bars', 'bubbles', and 'cylon', into Vue applications. The library is currently at version 1.3.2 and appears to be in an unmaintained or abandoned status, with its last npm publish over 7 years ago and GitHub activity ceasing around 2019. Its primary differentiator is the use of SVG for animations, which ensures scalability and high-quality rendering, and its simple integration as either a global Vue plugin or a local component. Due to its age, it is designed for Vue 2 applications and lacks direct compatibility with Vue 3's composition API or `createApp` paradigm.
Common errors
-
Error in main.js: "[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available." or similar template compilation errors.
cause `vue-loading-template` (like many Vue 2 components) relies on a Vue build that includes the template compiler if you are using it with inline templates (e.g., in a string template in a `.js` file or directly in `index.html`).fixEnsure your Webpack or build configuration is set up to use the full build of Vue (e.g., by aliasing `vue` to `vue/dist/vue.esm.js` in Webpack) if you are not using Single File Components (`.vue` files) which pre-compile templates. This is less common in modern Vue CLI setups but can occur in custom configurations. -
TypeError: Cannot read properties of undefined (reading 'use') at <App>
cause This error often occurs when attempting to use `Vue.use()` with a Vue 3 `createApp` instance or when `Vue` is not correctly imported or available globally.fixVerify that your project is indeed a Vue 2 project and that `Vue` is globally available or correctly imported as `import Vue from 'vue'`. If using Vue 3, this library is incompatible and you should seek a Vue 3-native alternative.
Warnings
- breaking This library is built exclusively for Vue 2. It is not compatible with Vue 3 due to fundamental changes in the Vue 3 API, including the `createApp` function and component registration process. Direct usage in a Vue 3 project will lead to runtime errors.
- gotcha The package appears to be unmaintained or abandoned, with no significant updates or bug fixes in over 7 years. This means it may not receive security patches, performance improvements, or compatibility updates for newer browser versions or Vue 2 minor releases.
- gotcha When installing as a global plugin using `Vue.use(VueLoading)`, the component is registered globally as `<vue-loading>`. Ensure there are no naming conflicts with other components or HTML tags.
Install
-
npm install vue-loading-template -
yarn add vue-loading-template -
pnpm add vue-loading-template
Imports
- VueLoading
import VueLoading from 'vue-loading-template'
import { VueLoading } from 'vue-loading-template' - VueLoading
import { VueLoading } from 'vue-loading-template'; Vue.use(VueLoading);import VueLoading from 'vue-loading-template'; Vue.use(VueLoading);
- VueLoadingOptions
import type { VueLoadingOptions } from 'vue-loading-template'
Quickstart
<template>
<div>
<h2>Loading Example</h2>
<p>Using the 'bars' type with custom color and size.</p>
<vue-loading type="bars" color="#d9544e" :size="{ width: '50px', height: '50px' }"></vue-loading>
<p>Another example with 'bubbles' type.</p>
<vue-loading type="bubbles" color="#5ac1dd"></vue-loading>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { VueLoading } from 'vue-loading-template';
export default defineComponent({
name: 'App',
components: {
VueLoading,
},
});
</script>