In Vue.js, the meaning of the dollar sign ($) prefix refers to the internal properties or methods of the Vue instance. These properties and methods are used internally by the Vue.js framework, and it is generally not recommended to access or modify them directly. The dollar sign prefix is ​​to distinguish the internal properties and methods of the Vue instance from the user-defined properties and methods.
P粉199248808
P粉199248808 2023-08-14 11:37:15
0
1
868
<p>In Vue.js, what is the meaning of the dollar sign prefix in front of the property name? </p> <p>For example: <code>this.$emit('clicked', 'demo')</code></p>
P粉199248808
P粉199248808

reply all(1)
P粉833546953

In Vue, an explanation of using the $ and _ prefixes can be found here:

https://v2.vuejs.org/v2/style-guide/#Private-property-names-essential

Details are explained in the section.

_For private instance properties:

$ is used for public instance properties:

Both are used to avoid conflicts with property names chosen by the component creator, such as props and data properties.

The

$ prefix is ​​not only used by Vue’s core API. It is also commonly used in libraries that add properties to components. For example:

    Vuex adds
  • $store.
  • Vue Router adds
  • $route and $router.
These are officially supported libraries, but so are many third-party libraries.

It can also be used by application code to create global properties. A common example is adding

$http to Vue.prototype (or globalProperties in Vue 3).

In all these cases,

$ serves as an indicator to future developers that the property is defined elsewhere, not inside the current component.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template