$ gnpm install @antv/g-compat
English | 简体中文
Provides partial G 4.0 compatible APIs, e.g.
// 4.0
circle.getCount();
// Equivalent to DOM API
circle.childElementCount;
Package name inspired by @vue/compat
.
https://v3-migration.vuejs.org/migration-build.html
The following APIs provided in G 4.0 can be replaced by the corresponding DOM APIs in the new version.
Get the number of child nodes.
circle.getCount(); // [0]
// Equivalent to
circle.childElementCount; // [0]
Get the parent node.
circle.getParent();
// Equivalent to
circle.parentElement;
Get the list of child nodes.
circle.getChildren();
// Equivalent to
circle.children;
Get the first child node.
circle.getFirst();
// Equivalent to
circle.firstElementChild;
Get the last child node.
circle.getLast();
// Equivalent to
circle.lastElementChild;
Get child nodes by index.
circle.getChildByIndex(index);
// Equivalent to
circle.children[index];
Add child nodes.
parent.add(child);
// Equivalent to
parent.appendChild(child);
Set the cropped graphics.
circle.setClip(clipPath);
// Equivalent to
circle.style.clipPath = clipPath;
Get cropped graphics.
circle.getClip();
// Equivalent to
circle.style.clipPath;
Set in the initialization configuration.
circle.set('my-prop', 1);
// Equivalent to
circle.config['my-prop'] = 1;
Obtain in the initialization configuration.
circle.get('my-prop');
// Equivalent to
circle.config['my-prop'];
Show node.
circle.show();
// Equivalent to
circle.style.visibility = 'visible';
Hide node.
circle.hide();
// Equivalent to
circle.style.visibility = 'hidden';
Moving node in the world coordinate system.
circle.moveTo(x, y, z);
circle.move(x, y, z);
// Equivalent to
circle.setPosition(x, y, z);
Set the zIndex
of node:
circle.setZIndex(100);
// Equivalent to
circle.style.zIndex = 100;
Copyright 2013 - present © cnpmjs.org | Home |