当前位置:网站首页>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>
边栏推荐
猜你喜欢

多线程基础部分Part3

NLP-D62-nlp比赛D31&刷题D15

Experience oceanbase database under win10

openstack实例重启状态就会变成错误处理方法,容器搭建的openstack重启计算节点compute服务方法,开机提示Give root password for maintenance处理方法

Open the door small example to learn ten use case diagrams

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

Redis high availability cluster (sentry, cluster)

齐纳二极管 稳压二极管 SOD123封装 正负区分

资深【软件测试工程师】学习线路和必备知识点

双位置继电器HJWS-9440
随机推荐
【Cocos Creator 3.5.1】坐标的加法
DAST black box vulnerability scanner part 6: operation (final)
【Cocos Creator 3.5.1】this.node.getPosition(this._curPos)的使用
Discussion on streaming media protocol (MPEG2-TS, RTSP, RTP, RTCP, SDP, RTMP, HLS, HDS, HSS, mpeg-dash)
leetcode298周赛记录
Remapping (STM32)
IAR Systems全面支持芯驰科技9系列芯片
Asp. Net core6 websocket simple case
【Cocos Creator 3.5.1】this. node. Use of getposition (this.\u curpos)
NLP-D62-nlp比赛D31&刷题D15
竣达技术丨多品牌精密空调集中监控方案
[nips 2017] pointnet++: deep feature learning of point set in metric space
C# netcore中 配置帮助类IConfiguration
RTP 发送PS流工具(已经开源)
网易云音乐params和encSecKey参数生成代码
1317. 将整数转换为两个无零整数的和
QListWidget中的内容不显示
Implementation of easyexcel's function of merging cells with the same content and dynamic title
What is BFC? What's the usage?
Unity中跨平臺獲取系統音量
