当前位置:网站首页>Why is everything console I can't come out. console. log(depsMap)
Why is everything console I can't come out. console. log(depsMap)
2022-04-21 22:44:00 【hamimelon2020】
When the variable is of primitive type Set Storage
When the object is a variable map Storage
Use when multiple objects weakMap Storage
https://www.gxlsystem.com/qianduan-20707.html
<!DOCTYPE html>
<html>
<head>
<title>document.write() Example</title>
</head>
<body>
<script type="text/javascript">
const data = {
ok:true, text:'hello world'}
const obj = new Proxy(data, {
get(target, key) {
// Collect side effect functions
track(target, key);
console.log(target[key])
return target[key]
},
set(target, key, newVal) {
target[key] = newVal;
// Remove side effects and perform
trigger(target, key);
}
})
// encapsulation track function , Tracking changes
function track(target, key) {
if (!activeEffect) return
let depsMap = bucket.get(target)
console.log(depsMap)
if (!depsMap) {
bucket.set(target, (depsMap = new Map()))
}
let deps = depsMap.get(key)
if (!deps) {
depsMap.set(key, (deps = new Set()))
}
deps.add(activeEffect)
}
// encapsulation trigger function , Trigger the deputy general manager to re execute with the function
function trigger(target, key) {
const depsMap = bucket.get(target)
if (!depsMap) return
const effects = depsMap.get(key)
console.log(effects)
effects && effects.forEach(fn => fn())
}
</script>
</body>
</html>
版权声明
本文为[hamimelon2020]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204212037094234.html
边栏推荐
- 君禾股份:2021年度营收增长稳健,受益产品出口业绩再创新高
- L1-059 敲笨钟 (20 分)
- 1957 college entrance examination mathematics problems
- L1-061 新胖子公式 (10 分)
- Oracle Database 22c 管窥:_kgl_large_heap_assert_threshold 自动和手动调节
- Opencv -- histogram processing
- Reading notes "autumn garden", "driftwood", "my fragrance"
- [feignclient] feignclient downloads files across services
- Nacos Registry - service registration and tiered storage
- 【mq】从零开始实现 mq-01-生产者、消费者启动
猜你喜欢

诚邀报名丨首期OpenHarmony开发者成长计划分享日

2022年中级会计职称考试经济法练习题及答案

Eventbridge integrated cloud service practice

Recursive stack with the help of classical recursive tree

2022年一级注册建筑师考试建筑材料与构造复习题及答案

openCV——直方图处理
Event distribution mechanism Android, Android interview summary of large manufacturers, detailed answers

每日练题(3)

OS实验三【进程通信】

CC00012. MySQL———————————————
随机推荐
Introduction to cyclone IV e series
Event distribution mechanism Android, Android interview summary of large manufacturers, detailed answers
OpenCV中的图像处理——离散傅里叶变换实例(11)
L1-058 6翻了 (15 分)
L1-056 guess the number (20 points)
Keil package common chip high-speed download address, including historical version, pay close attention to my quick collection
Collection of some websites
JUNHE shares: the revenue growth in 2021 was steady, and the export performance of benefited products reached a new high
Mysql的并发参数调整详解
Opencv -- geometric transformation
1957年高考数学题
【FPGA的基础学习-------OV7725摄像头模块】
Fundamentals of Power Electronics
OpenCV中的Core组件——输入输出XML, YAML(12)
Sorting methods (8 kinds) detailed explanation 6 - quick sorting
Lesson 5: correlation coefficient
Module 3: Outsourcing student management system - architecture design document
Logic control (example explanation)
循环队列与扩容
【中南林业科技大学】【陈】第六周创新题素数