无法阅读财产'取消订阅'未定义的
<!doctype html>
<head>
<script>
function change() {
var paragraph = document.getElementById("whytrust");
paragraph.innerHTML="I am trustworthy, but how can you be sure?";
}
</script>
</head>
<body>
<p id="whytrust" onclick="change();">You can trust me, but how can you be sure?</p>
</body>
</html>
HALP!?
答案 0 :(得分:0)
在此上下文中,this
是窗口对象,而不是record
。
function record(){
event;
}
record.prototype = {
start: function (){
keyUp = Rx.Observable.fromEvent(document, "keyup");
record.event = keyUp.subscribe((key) => {console.log(key)});
},
stop: function (){
record.event.unsubscribe();
}
}
rec = new record();
rec.start();
setTimeout(rec.stop, 2000);