MVVM模型
文章发布较早,内容可能过时,阅读注意甄别。
# 代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MVVM模型</title>
<script src="../js/vue.js"></script>
</head>
<body>
<!-- 准备好一个容器 -->
<div id="root">
<h1>博客名称:{{name}}</h1>
<h1>博客地址:{{url}}</h1>
</div>
<script type="text/javascript">
Vue.config.productionTip = false; // 禁用提示
new Vue({
el: "#root",
data: {
name: "二丫讲梵",
url: "https://wiki.eryajf.net",
},
});
</script>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 笔记
MVVM 模型
M模型(Model) :
data 中的数据V视图(View) :
模板代码VM视图模型(ViewModel):
Vue 实例
观察发现:
- data 中所有的属性,最后都出现在了 vm 身上。
- vm 身上所有的属性,及 Vue 原型上所有属性,在 Vue 模板中都可以直接使用。
![微信](https://t.eryajf.net/imgs/2023/01/834f12107ebc432a.png)
![支付宝](https://t.eryajf.net/imgs/2023/01/fc21022aadd292ca.png)
上次更新: 2024/06/13, 22:13:45
← el与data的两种写法 数据代理→
- 01
- 学习周刊-总第169期-2024年第30周07-26
- 02
- 使用docker快速部署rancher-2.8.5并投入生产实践07-20
- 03
- 学习周刊-总第168期-2024年第29周07-18