Home > Web Front-end > Vue.js > What does the dollar symbol mean in vue

What does the dollar symbol mean in vue

WBOY
Release: 2022-03-24 15:39:58
Original
3969 people have browsed it

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.

What does the dollar symbol mean in vue

The operating environment of this article: Windows 10 system, Vue version 2.9.6, DELL G3 computer.

What does the dollar symbol mean in vue

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` 改变后调用
})
Copy after login

[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!

Related labels:
vue
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template