vuepress-theme-vdoing/docs/《Vue》笔记/01.基础/00.MVVM模式.md

43 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: MVVM模式
date: 2020-02-04 12:19:00
permalink: /pages/114158caa9e96df0
categories:
- 《Vue》笔记
- 基础
tags:
- Vue
author:
name: xugaoyi
link: https://github.com/xugaoyi
---
:::tip
说明本章内容是博主的Vue学习笔记以[官方文档](https://cn.vuejs.org/v2/guide/)为准。
:::
# MVVM模式
MVVM模式`M`即 model数据模型`V`即 view视图`VM`即 view-model视图模型。
<!-- more -->
![](https://cdn.staticaly.com/gh/xugaoyi/image_store/blog/20200204123438.png)
**理解**
首先数据Model通过Data Bindings把数据绑定在View视图上
当View视图有交互有改变的时候Dom listeners会自动监听然后更新数据Model。
**Q什么是MVVM模式**
AMVVM模式第一个M代表数据模型V代表视图VM代表视图模型
它的实际操作原理是:后台数据通过视图模型来渲染视图,就是页面。当用户在页面上进行操作的时候,
视图模型会自动监听到用户的操作,从而改变后台数据。