var s = document.write;
s("a");
这样写出后 报错
VM36:3 Uncaught TypeError: Illegal invocation
at <anonymous>:3:1
因为s() 张样写的话 this的指向了全局 或window了 ,而页面的是dom操作,因此采用bind()方法将其在指向dom
正确的方法是 s.bind(document)('a').
var s = document.write;
s("a");
这样写出后 报错
VM36:3 Uncaught TypeError: Illegal invocation
at <anonymous>:3:1
因为s() 张样写的话 this的指向了全局 或window了 ,而页面的是dom操作,因此采用bind()方法将其在指向dom
正确的方法是 s.bind(document)('a').