我有基于纯JavaScript的此类:
var DrawFeatureP = /*@__PURE__*/(function (Draw) {
function DrawFeatureP() {
debugger
Draw.call(this, {
source: new ol.layer.Vector({ source: new ol.source.Vector() }),
type: 'change this property from function in pottom'
});
document.getElementById('lineToggle').onclick = this.handleDrawFeature.bind(this);
}
if (Draw) DrawFeatureP.__proto__ = Draw;
DrawFeatureP.prototype = Object.create(Draw && Draw.prototype);
DrawFeatureP.prototype.constructor = DrawFeatureP;
DrawFeatureP.prototype.handleDrawFeature = function handleDraw(evt) {
//when is function is fired how ca i set 'type' property?
};
return DrawFeatureP;
}(ol.interaction.Draw));
当该函数被触发时:
DrawFeatureP.prototype.handleDrawFeature = function handleDraw(evt) {
//when is function is fired how ca I set 'type' property?
};
我需要更改'type'属性:
type: 'change this property from function in the bottom'
我的问题是如何从handleDraw函数编辑type属性?
Since you bind
this
when assigning theonclick
handler, you can usethis.type
in the handler function.