1
我不知道如何处理这个用户交互问题。 API是3DMolJS/TS必须使用绑定,但仍然需要原始的
我试图同时访问this
元素
model.setClickable({chain: theChain, resi: mappedPosition}, true, function(){
console.log(this);
});
首先,对于原执行如上this
将用户点击的位置。不过,我还需要将点击位置与来自外部调用对象的某个值相结合。
我试过.bind(null,this)
但功能this
设置为null
。
我尝试了封闭
const clickClosure = function(){
const mutations = self.alignment.mutations;
function clicker(){
console.log(this);
console.log(mutations);
}
return clicker();
}
model.setClickable({chain: theChain, resi: mappedPosition}, true,clickClosure);
发现突变存在,但是没有定义this
。任何想法如何获得这两个不使用全局变量?
谢谢!我完全忘了lambda notation =>它现在起作用了 –