【问题标题】:How to use a ViroReact function in other components?如何在其他组件中使用 ViroReact 函数?
【发布时间】:2021-05-06 13:28:08
【问题描述】:

我正在尝试使用 viroReact 查找图像,然后显示一些媒体内容。

我想这样做,以便在找到锚点后我可以转到自定义反应视图,因为无法在带有 viro 的 AR 场景中显示基本反应元素。

我考虑过从 app.js 类(主类)调用一个函数来完成工作,如下所示:

<ViroARImageMarker target={"fleur"}
        onAnchorFound={this.mainClass.navigateTowherever}

这行得通吗?还是有更好的办法?

【问题讨论】:

    标签: reactjs react-native viro-react


    【解决方案1】:

    考虑使用ViroFlexView 来呈现您需要的内容,就像使用普通的View 一样:

    <ViroFlexView style={{flexDirection: 'row', padding: .1}} 
                  width={5.0} height={5.0} 
                  position={[-5.0, 0.0, -2.0]}
                  rotation={[0, 45, 0]} >
      <ViroImage source={require('./res/myImage1.jpg')} style={{flex: .5}} />
      <ViroImage source={require('./res/myImage2.jpg')} style={{flex: .5}}/>
    </ViroFlexView>
    

    查看文档:https://docs.viromedia.com/docs/viroflexview

    【讨论】:

      猜你喜欢
      • 2019-11-12
      • 2017-12-12
      • 1970-01-01
      • 2019-12-26
      • 1970-01-01
      • 2014-12-25
      • 1970-01-01
      • 1970-01-01
      • 2020-09-05
      相关资源
      最近更新 更多