- 注册时间
- 2014-9-22
- 最后登录
- 2017-7-29
- 阅读权限
- 20
- 积分
- 86
- 精华
- 0
- 帖子
- 16
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
canvas{border: 1px solid red;}
</style>
</head>
<body>
<canvas id="canvas" width="400" height="400"></canvas>
<script type="text/javascript">
var myObject = function(){
var _self = this;
_self.config = {
cvs:null,
ctx:null,
cW:0,
cH:0
};
};
myObject.prototype = {
init:function(){
var _self = this;
_self.config.cvs = document.getElementById("canvas");
_self.config.ctx = _self.config.cvs.getContext("2d");
_self.config.cW = _self.config.cvs.width;
_self.config.cH = _self.config.cvs.height;
_self.testFun();
_self.utilEvent();
},
utilEvent:function(){
var _self = this;
_self.config.cvs.addEventListener("touchmove", _self.touchMove.bind(this),false);
},
touchMove:function(e){
e.preventDefault();
e = e.touches[0];
console.log("t1",this);
myObject.call(this);
var _self = this;
console.log("touchStart:",_self.config.cW);
},
testFun:function(){
var _self = this;
console.log("testFun:",_self.config.cW);
}
};
var _obj = new myObject();
_obj.init();
</script>
</body>
</html>
我知道this 指向变了,可是我用了call 方法,但是 得到的结果 为什么一个是 400,一个是 0,麻烦大神指点一二,多谢
|
|