YouTip LogoYouTip

Vue Ref Options

Options in Vue are the different options available on Vue instances when using the Options API. Some common Vue instance options: * **el** - Specifies the DOM element where the Vue instance will be mounted. If not provided, the Vue instance will not be automatically mounted. * **data** - Defines the data object of the Vue instance. The template, computed properties, methods, watchers, etc. of the Vue instance can all access this data. * **computed** - Contains computed properties, whose values are cached based on their dependencies. Computed properties are only re-evaluated when their dependencies change. * **methods** - Defines methods for the Vue instance, which can be called in templates through event listeners. * **watch** - Contains one or more watchers for observing and responding to changes in Vue instance data. * **props** - Defines external data that a component can receive. * **components** - Allows registering custom components in the Vue instance. * **directives** - Allows registering global custom directives. * **filters** - Defines filters that can be used in templates for text formatting. * **model** - Specifies the custom v-model property and events used by the component. * **provide/inject** - Provides dependency injection capability, allowing data to be passed across components. * **lifecycle hooks** - Includes lifecycle hooks such as `onMounted`, `onUpdated`, `onUnmounted`, used to execute code at different stages of the Vue instance. * **template** - Defines the HTML template of the Vue instance. * **render function** - Allows using JavaScript functions to render components, providing more advanced customization capabilities. * **errorCaptured** - Used to globally capture errors from Vue instances. * **emits** - Defines events that the component can emit. * **setup** - The entry function in Vue 3's Composition API, used to organize component logic. ### `el` Mount point, used to specify the DOM element where the Vue instance will be mounted: ## Example const app = Vue.createApp({ // options }); app.mount('#app'); ### `data` * **Type**: Function or Object * **Role**: `data` is the place where Vue instance stores component data. You can define various data properties in `data` and use them on the page through template syntax. The data in `data` is reactively updated, meaning when data changes, the related page content will automatically update. ## Example const app = Vue.createApp({ data(){ return{ message:'Hello Vue!' }; } }); ### `computed` * **Type**: Object * **Role**: `computed` properties allow you to declare computed properties based on reactive dependencies. Computed properties are only re-evaluated when their related dependencies change, and they cache the computed results to avoid unnecessary recalculations. ## Example const app = Vue.createApp({ data(){ return{ firstName:'John', lastName:'Doe' }; }, computed:{ fullName(){ return `${this.firstName}
← Cpp Libs IostreamVue3 Builtin Attributes β†’