P粉8335469532023-08-15 11:14:15
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:
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:
.
and
$router.
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).
$ serves as an indicator to future developers that the property is defined elsewhere, not inside the current component.