function ContinuousForceDirectedLayout() { go.ForceDirectedLayout.call(this); this._isObserving = false; this.defaultDirection = go.LayoutDirection.Right; 报错了
时间: 2024-01-12 12:03:41 浏览: 15
如果你将 `defaultDirection` 属性加入到 `ContinuousForceDirectedLayout` 的构造函数中,但是出现了报错,可能是因为 `defaultDirection` 属性在 `go.ForceDirectedLayout` 中不存在。
你可以尝试在 `ContinuousForceDirectedLayout` 的构造函数中添加以下代码,以判断 `defaultDirection` 属性是否可用:
```
console.log(go.ForceDirectedLayout.prototype.hasOwnProperty('defaultDirection'));
```
如果输出结果为 `false`,说明 `go.ForceDirectedLayout` 中并没有 `defaultDirection` 属性,因此你需要将 `defaultDirection` 属性加入到 `ContinuousForceDirectedLayout` 中:
```
function ContinuousForceDirectedLayout() {
go.ForceDirectedLayout.call(this);
this._isObserving = false;
this.defaultDirection = go.LayoutDirection.Right;
}
go.Diagram.inherit(ContinuousForceDirectedLayout, go.ForceDirectedLayout);
```
这样,`defaultDirection` 属性就可以被 `ContinuousForceDirectedLayout` 使用了。