当前位置:网站首页>js实现双向数据绑定
js实现双向数据绑定
2022-06-27 05:41:00 【小-黯】
<!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>Document</title>
</head>
<body>
<input type="text" value="1" id="input">
<script>
var obj ={
}
var input = document.getElementById('input');
Object.defineProperty(obj, "txt", {
get: function(){
console.log("读取数据");
return input.value;
},
set: function(val){
console.log("修改数据", val);
input.value = val;
}
})
input.addEventListener("keyup", function(e){
obj.txt = input.value;
})
</script>
</body>
</html>
边栏推荐
- 多线程基础部分Part 1
- 躲避小行星游戏
- RTP sending PS stream tool (open source)
- 【Cocos Creator 3.5.1】input.on的使用
- 微信小程序WebSocket使用案例
- When STM32 turns off PWM output, it is a method to fix IO output at high or low level.
- Neon optimization 1: how to optimize software performance and reduce power consumption?
- Wechat applet websocket use case
- Webrtc Series - Network Transport 7 - ice Supplement nominations and ice Modèle
- 微信小程序刷新当前页面
猜你喜欢

Two position relay xjls-8g/220

neo4j图数据库基本概念

LeetCode-515. Find the maximum value in each tree row

EasyExcel合并相同内容单元格及动态标题功能的实现
![[nips 2017] pointnet++: deep feature learning of point set in metric space](/img/3e/0a47eecc27f236d629c611e683b37a.png)
[nips 2017] pointnet++: deep feature learning of point set in metric space

Zener diode zener diode sod123 package positive and negative distinction

【NIPS 2017】PointNet++:度量空间中点集的深层次特征学习

leetcode298周赛记录

Vue学习笔记(五)Vue2页面跳转问题 | vue-router路由概念、分类与使用 | 编程式路由导航 | 路由组件的缓存 | 5种路由导航守卫 | 嵌套路由 | Vue2项目的打包与部署

Experience oceanbase database under win10
随机推荐
Built in functions of spark
Remapping (STM32)
RTP sending PS stream tool (open source)
Wechat applet refreshes the current page
Web3 has not been implemented yet, web5 suddenly appears!
导航【机器学习】
Unity中跨平臺獲取系統音量
【合辑】点云基础知识及点云催化剂软件功能介绍
多线程基础部分Part3
Two position relay xjls-8g/220
竣达技术丨多品牌精密空调集中监控方案
Experience oceanbase database under win10
Quick sort (non recursive) and merge sort
Webrtc series - Nomination and ice of 7-ice supplement for network transmission_ Model
Two position relay hjws-9440
three. JS first person camera gun following
数据库-索引
Redis4.0新特性-主动内存碎片整理
NEON优化1:软件性能优化、降功耗怎么搞?
[FPGA] design and implementation of frequency division and doubling based on FPGA
