Home > Web Front-end > Vue.js > body text

What is vm in vue

WBOY
Release: 2022-03-18 17:01:00
Original
10355 people have browsed it

In vue, vm is the abbreviation of ViewModel, which means view model and is the bridge connecting view and model; ViewModel can monitor data changes and then notify the corresponding view to automatically update, achieving two-way Binding.

What is vm in vue

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

What is vm in vue

VM is actually ViewModel--view model.

MVVM View-Model-ViewModel

[View] refers to the page you see, and [Model] refers to the data passed by the backend.

[View Model] The core of mvvm mode, it is the bridge connecting view and model; it has two directions:

One is: convert [Model] into [View], that is, The data passed by the backend is converted into the page seen. The way to achieve this is: data binding.

The second is: Convert [View] into [Model], that is, convert the page you see into back-end data. The way to implement it is: DOM event monitoring.

If these two directions are implemented, we call it [two-way binding] of data.

Under the MVVM framework, views and models cannot communicate directly. They communicate through ViewModel. ViewModel usually implements an observer. When the data changes, ViewModel can monitor the change in data and then notify the corresponding view to automatically update.

When the user operates the view, the ViewModel can also monitor changes in the view and then notify the data to make changes. This actually realizes two-way binding of data. And View and ViewModel in MVVM can communicate with each other.

【Related recommendation: "vue.js Tutorial"】

The above is the detailed content of What is vm 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!