1, 问题 , 在原来的事件之前添加一个功能,例如获取之前的数据,
2 解决使用 promise 对数据进行加工
3
const getValue = ()=> {
return new Promse((resove,rejecte)=> {
return resove
})
}
使用
getValue().then(()=> {
sentValue()
})
别的方案
直接方法传输
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
</body>
<script>
// 定义一个函数,用于接收一个包含 name 属性的对象并打印 name
const getvalue = function ({ name }) {
console.log(name);
};
// 定义一个函数,用于调用传入的函数并传递对象参数
const sentValue = (functionName, value) => {
functionName({ ...value });
};
// 定义一个包含 name 属性的对象
const data = { name: "jkkkk" };
// 使用 bind 方法创建一个新函数,固定第一个参数为 getvalue
const newDta = sentValue.bind(this, getvalue);
// 调用新函数,传递对象参数
newDta(data);
// 直接调用 sentValue 函数
sentValue(getvalue, data);
</script>
</html>