Ref 方法(Rive Ref Methods)
新版 Runtime(推荐)
通过 useRive() 获取 riveViewRef 后可调用:
play(): Promise<void>:开始播放pause(): Promise<void>:暂停reset(): Promise<void>:重置到初始状态playIfNeeded(): void:必要时触发播放(常用于属性更新后)awaitViewReady(): Promise<boolean>:等待视图可用bindViewModelInstance(vmi): void:绑定视图模型实例getViewModelInstance(): ViewModelInstance | undefined:读取当前绑定实例
已弃用(Deprecated)
以下方法仍存在但建议迁移到 Data Binding:
setTextRunValue/getTextRunValuesetNumberInputValue/getNumberInputValuesetBooleanInputValue/getBooleanInputValuetriggerInputonEventListener/removeEventListeners
Legacy Runtime
Legacy ref 常用方法:
play()/pause()/stop()/reset()fireState(stateMachineName, inputName)setInputState(stateMachineName, inputName, value)setTextRunValue(textRunName, value)