![]() |
A Vue.js Instance refers to a Vue constructor’s instance in the Vue application. It acts as a container that holds your application’s data and methods. Vue.js implements the Component-Based Architecture that enables the generation of these instances, in order to represent and manage individual components or specific sections of the Vue Application. Each Instance is responsible for performing the specific task that enhances the functionality & interface of the web application. In this article, we will learn how to create a VueJS instance. SyntaxIn the below code snippet, new Vue({…}) initializes a new Vue instance and accepts an object with various options and data properties. const app = new Vue({ setup() { // Your code here } }) Vue.JS installationThere are the following ways to install Vue.JS:
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
Write the following command in the terminal npm install vue ApproachTo create an instance in VueJS, follow the below steps:
Example 1: In this example, we will be creating a simple VueJS Instance that renders the Hello GeeksforGeeks text. HTML
Output: Example 2: In this example, we will create a simple VueJS instance representing a counter app. HTML
Output: |
Reffered: https://www.geeksforgeeks.org
Geeks Premier League |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |