我试图在React Konva中对Transformer Component进行一些更改,并且每当我尝试更改锚点大小时都会遇到此错误。我遵循文档中所述的语法 - https://konvajs.github.io/api/Konva.Transformer.html#validateAnchors__anchor
问题出在anchorSize中。请帮我。这是代码 -
class TransformerComponent extends React.Component {
componentDidMount () {
this.checkNode ();
}
componentDidUpdate () {
this.checkNode ();
}
checkNode() {
const stage = this.transformer.getStage();
const { selectedShapeName } = this.props;
const selectedNode = stage.findOne ('.' + selectedShapeName);
this.transformer.rotateEnabled (false);
this.transformer.anchorSize (5);
if (selectedNode === this.transformer.node()) {
return;
}
if (selectedNode) {
this.transformer.attachTo (selectedNode);
}
else {
this.transformer.detach();
}
this.transformer.getLayer().batchDraw();
}
render() {
return (
<Transformer
ref = {node => {
this.transformer = node;
}}
/>
);
}
}
anchorSize
是最近推出的一个非常新的物业。尝试将Konva
更新到最新版本。
您需要将此绑定到checkNode()
,如下所示:
class TransformerComponent extends React.Component {
constructor(props) {
super(props)
this.checkNode = this.checkNode.bind(this)
}
...