cesiumlab / cesiumlab/XbsjEarthUI
我在类里加了两个属性, 但是this.toJSON()方法不会把这两个属性转成JSON请问 怎样设置才能保存这两个属性呢?
- Dominant language
- JavaScript
- Stars
- 734
- Forks
- 193
- PR merge metrics
- No merged PRs in 30d
Description
@vtxf 求问~ 我在类里加了两个属性, 但是this.toJSON()方法不会把这两个属性转成JSON请问 怎样设置才能保存这两个属性呢?


---
可以参考自定义图元库中的写法:
https://github.com/cesiumlab/CustomPrimitive-EarthSDK/blob/master/src/Tube.js
1 首先定义defaultOptions
[图片]

2 然后将其与自定义的类关联起来:
Tube.defaultOptions = defaultOptions;
[图片]

3 注意代码中就不要再用 XE.MVVM.extend(...)来定义相关变量了
4 通过以上方法定义的变量是可以存储的
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the class that calls this.toJSON() and inspect how its properties are declared, especially use of XE.MVVM.extend(...). Compare that serialization setup with src/Tube.js in the linked CustomPrimitive-EarthSDK example. Done means the two added properties appear in the serialized JSON and can be saved and restored.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100