Ai
1 Star 0 Fork 0

cyc川/Vue.js_study

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
computed_watch.html 939 Bytes
一键复制 编辑 原始数据 按行查看 历史
cyc川 提交于 2020-05-19 18:41 +08:00 . init
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>计算属性与侦听器</title>
<script src="./vue.js"></script>
</head>
<body>
<div id="root">
姓:<input v-model="firstName"/>
名:<input v-model="lastName"/>
<div>{{fullName}}</div>
<div>{{count}}</div>
</div>
<script>
new Vue({
el: "#root",
data: {
firstName: '',
lastName: '',
count: 0
},
//计算属性
computed: {
fullName: function () {
return this.firstName + ' ' + this.lastName
}
},
//侦听器:监听某个数据,当数据发生改变时,执行具体业务逻辑
watch: {
firstName: function () {
this.count++
},
lastName: function () {
this.count++
}
}
})
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cyc_zero/Vue.js_study.git
git@gitee.com:cyc_zero/Vue.js_study.git
cyc_zero
Vue.js_study
Vue.js_study
master

搜索帮助