Search results

Getting Started with Vue 3 in Vue ProgressBar component

14 Oct 2021 / 3 minutes to read

This section explains how to use Progress Bar component in Vue 3 application.

Prerequisites

  • vue : 3+
  • node : 10.15+
  • vue-class-component : 8.0.0-rc.1

Creating Vue application using Vue CLI

The easiest way to create a Vue application is to use the Vue CLI. Vue CLI versions above 4.5.0 are mandatory for creating applications using Vue 3. Use the following command to uninstall older versions of the Vue CLI.

Copied to clipboard
npm uninstall vue-cli -g

Use the following commands to install the latest version of Vue CLI.

Copied to clipboard
npm install -g @vue/cli
npm install -g @vue/cli-init

Create a new project using the command below.

Copied to clipboard
vue create quickstart

Initiating a new project prompts us to choose the type of project to be used for the current application. Select the option Default (Vue 3 Preview) from the menu.

Vue 3 Terminal

Adding Syncfusion Progress Bar package in the application

Syncfusion Vue packages are maintained in the npmjs.com registry. The Progress Bar component will be used in this example. To install it in the quickstart folder use the following command.

Copied to clipboard
npm install @syncfusion/ej2-vue-progressbar --save

Adding Syncfusion Progress Bar component in the application

You have completed all the necessary configurations needed for rendering the Syncfusion Vue component. Now, you are going to add the Progress Bar component using following steps.

  1. Import the Progress Bar component in the <script> section of the src/App.vue file.
Copied to clipboard
<script>
import { ProgressBarComponent } from "@syncfusion/ej2-vue-progressbar";
</script>
  1. Register the Progress Bar component which is used in this example. Find the list of child directives and tag names that can be used in the Progress Bar component in the following table.
Directive Name Tag Name
ProgressBarAnnotationsDirective e-progressbar-annotations
ProgressBarAnnotationDirective e-progressbar-annotation
Copied to clipboard
import { ProgressBarComponent } from "@syncfusion/ej2-vue-progressbar";

//Component registration.
export default {
  name: "App",
  components: {
    "ejs-progressbar": ProgressBarComponent
  }
};
  1. Add the Progress Bar component definition in template section.
Copied to clipboard
<template>
  <ejs-progressbar id="percentage" :type='type' :showProgressValue='showProgressValue' :value='value' :animation="animation"></ejs-progressbar>
</template>

Above is the Progress Bar component definition with type, value, showProgressValue and animation properties.

  1. Declare the bound properties in the script section.
Copied to clipboard
export default {
  name: "App",
  components: {
    "ejs-progressbar": ProgressBarComponent
  },
  data() {
    return {
      type: 'Circular',
      showProgressValue: 'true',
      value: 100,
      animation: {
        enable: true,
        duration: 2000,
        delay: 0
      }
    };
  },
};
  1. Summarizing the above steps, update the src/App.vue file with following code.
Copied to clipboard
<template>
  <ejs-progressbar id="percentage" :type='type' :showProgressValue='showProgressValue' :value='value' :animation="animation">
  </ejs-progressbar>
</template>

<script>
import { ProgressBarComponent } from "@syncfusion/ej2-vue-progressbar";

export default {
  name: "App",
  components: {
    "ejs-progressbar": ProgressBarComponent
  },
  data() {
    return {
      type: 'Circular',
      showProgressValue: 'true',
      value: 100,
      animation: {
        enable: true,
        duration: 2000,
        delay: 0
      }
    };
  },
};
</script>
  1. Run the application using the following command.
Copied to clipboard
npm run serve

The web server will be initiated and open the quickstart app in the browser at port localhost:8080.

Output

Refer the following sample, vue3-progressbar-getting-started.