The dollar symbol in vue is a special mark with no special meaning. Its main function is to enhance the distinction; it can distinguish the built-in instance method properties and user-defined properties, and avoid declaring or adding custom properties. cover.
The operating environment of this article: Windows 10 system, Vue version 2.9.6, DELL G3 computer.
Vue instances also expose some useful instance properties and methods. They are prefixed with $ to distinguish them from user-defined properties.
is just a special mark. To enhance the distinction, to indicate that this is a built-in instance method attribute.
Avoid declaring or adding custom attributes ourselves that will cause overwriting
For example:
var data = { a: 1 } var vm = new Vue({ el: '#example', data: data }) vm.$data === data // => true vm.$el === document.getElementById('example') // => true // $watch 是一个实例方法 vm.$watch('a', function (newValue, oldValue) { // 这个回调将在 `vm.a` 改变后调用 })
[Related recommendations: "vue.js tutorial"]
The above is the detailed content of What does the dollar symbol mean in vue. For more information, please follow other related articles on the PHP Chinese website!