If you want to use the package with a CDN, you need to include the CDN link inside a <script>
tag and then insert this tag into your HTML file:
<script src="https://unpkg.com/vue"></script>
<script src='https://unpkg.com/vue3-loading-shimmer'></script>
xmlNext, you need to register the component.
<script>
const { createApp } = Vue;
const App = {
//Component code...
};
const app = createApp(App);
app.component("vue3-loading-shimmer", Vue3LoadingShimmer);
app.mount("#app");
</script>
xmlAfter completing the steps to include the component in your project, you will be able to use it immediately. Here is an example of how to use it:
<div>
<vue3-loading-shimmer class="my-class" />
</div>
xml<style>
.my-class {
height: 1rem;
width: 100%;
}
</style>
xmlTo install the package package in your Vue.js project, you can use the following command:
npm install vue3-loading-shimmer --save
bash This will download and install the package and save it to your package.json
file as a dependency.
Global Registration
Once the package is installed, you can register it globally in your Vue.js application by importing it and registering it as a component globally
import { createApp } from "vue";
import App from "./App.vue";
import Shimmer from "vue3-loading-shimmer";
const app = createApp(App);
app.component("vue3-loading-shimmer", Vue3LoadingShimmer);
jsAfter registering the component globally, you can use it in any component template in your application by referencing it with its tag name.
<template>
<vue3-loading-shimmer class="my-class"/>
</template>
<style>
.my-class {
height: 1rem;
width: 100%;
}
</style>
xmlLocal Registration
Alternatively, you can register the component locally in a specific component by importing it and defining it in the components
components property of the component definition object.
import { defineComponent } from "vue";
import Package from "package";
export default defineComponent({
components: {
Shimmer,
},
});
jsAfter registering the component locally, you can use it in the template of that component by referencing it with its tag name.
<template>
<vue3-loading-shimmer class="my-class"/>
</template>
<style>
.my-class {
height: 1rem;
width: 100%;
}
</style>
xml