在Konvajs 2.5中,我曾经能够按照Readme中的说明通过定位特定的src文件来进行最少的导入。例:

import Konva from 'konva/src/Core'
import 'konva/src/Layer'


使用v3.0.0,整个库都被重写为TypeScript。我的应用程序不在TypeScript中,可能很长一段时间都没有。如何利用3.0中的树状握手功能?我会卡在旧版本中吗?我想要3.0的性能提升,因为我使用了大量的模式。

最佳答案

[email protected]支持最小捆绑:

import Konva from 'konva/lib/Core';
// now you have Konva object with Stage, Layer, FastLayer, Group, Shape and some additional utils function.
// Also core currently already have support for drag&drop and animations.
// BUT there are no shapes (rect, circle, etc), no filters.

// but you can simply add anything you need:
import { Rect } from 'konva/lib/shapes/Rect';
// importing a shape will automatically inject it into Konva object

var rect1 = new Rect();
// or:
var shape = new Konva.Rect();

// for filters you can use this:
import { Blur } from 'konva/lib/filters/Blur';

10-06 00:28