<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<button onclick="func()">click</button>
// 打印 undefined
<button onclick="app.handleClick()">click</button>
// 打印 App
<script>
class App {
handleClick() {
console.log(this)
}
}
const app = new App
const func = app.handleClick
</script>
</body>
</html>
↧
如何解释es6 class中this的表现?
↧