ajiho / delegateify Goto Github PK
View Code? Open in Web Editor NEW一个轻量级的事件委托(jQuery的on方法现代化替代品)
License: MIT License
一个轻量级的事件委托(jQuery的on方法现代化替代品)
License: MIT License
在jQuery中可以这样使用
$(document).on('click scroll',function(){
})
$('.selector').on('click',function(){
})
可以看到jQuery的用法
在delegateify中也可以实现类似的用法
delegateify(document).on('click scroll',function(){
})
delegateify('.selector').on('click',function(){
})
目前的使用方式,也不是不能用,等有空了,再支持吧,记录一下,免得忘记了
<!DOCTYPE html>
<html lang="en">
<head>
<title>Home</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
</head>
<body>
<script src="https://unpkg.com/delegateify@latest/dist/delegateify.min.js"></script>
<div class="box">
<div>dsada</div>
<button>btn</button>
</div>
<script>
new Delegateify('.box').on(
'touchstart',
`button`,
function (event) {
console.log('touchstart');
}
)
// document.querySelector('button').addEventListener('touchstart', function (event) {
// console.log('touchstart22');
// }, {
// passive: true
// })
</script>
</body>
</html>
解决办法就是添加passive: true
,希望支持这个参数,这样就可以解决这个在控制台的警告问题
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.