小编Est*_*uan的帖子

如何在每毫秒滴答一次的 onTick 事件中设置状态

我正在尝试在 onTick 事件中为时钟设置一个状态。

 <Viewer>
   <Clock
        startTime={start.clone()}
        stopTime={stop.clone()}
        currentTime={start.clone()}
        multiplier={50}
        onTick={_.throttle(handleValue, 1000)} // this thing ticks every millisecond
      />
    <Entity
          ref={ref} // here is the ref to get the value I want to set state with
          position={positionProperty}
          tracked
          selected
          model={{ uri: model, minimumPixelSize: 100, maximumScale: 100.0 }}
          availability={
            new TimeIntervalCollection([
              new TimeInterval({ start: start, stop: stop }),
            ])
          }
        />
 </Viewer>

Run Code Online (Sandbox Code Playgroud)

这是 handleValue 函数。

  const handleValue = (clock) => {
//setting the state here ( I want to display the chaning …
Run Code Online (Sandbox Code Playgroud)

javascript cesium reactjs

6
推荐指数
1
解决办法
247
查看次数

标签 统计

cesium ×1

javascript ×1

reactjs ×1