搜索文档
lynx.__globalProps 是一个全局变量,它是一个对象,你可以在任何地方访问它。
lynx.__globalProps
// `lynx.__globalProps` 中的属性不由 Lynx 管理,因此你必须自行扩展这个接口。 declare module '@lynx-js/types' { interface GlobalProps { appTheme: string; title: string; } } function App() { const themeClass = useMemo( () => `theme-${lynx.__globalProps.appTheme}`, [lynx.__globalProps.appTheme], ); return ( <view class={themeClass}> <text>{lynx.__globalProps.title}</text> </view> ); }
在 LynxView 提供了接口设置 __globalProps
LynxView
__globalProps
void updateGlobalProps(@NonNull Map<String, Object> props) void updateGlobalProps(@NonNull TemplateData props)
- (void)updateGlobalPropsWithDictionary:(NSDictionary<NSString*, id>*)data - (void)updateGlobalPropsWithTemplateData:(LynxTemplateData*)data
LCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.