【发布时间】:2020-01-11 11:31:12
【问题描述】:
我想使用 react-native 创建一个动态抽屉菜单导航。所有菜单项都从一个 json 文件中列出。
提前致谢!
【问题讨论】:
-
我发现这个很有帮助,也许可以看看stackoverflow.com/questions/48333738/…
标签: react-native react-native-navigation
我想使用 react-native 创建一个动态抽屉菜单导航。所有菜单项都从一个 json 文件中列出。
提前致谢!
【问题讨论】:
标签: react-native react-native-navigation
考虑到 boostrap:
render() {
return (
<div>
{ this.state.dynamicDrawer
&&
<div className="btn-group-vertical" data-toggle="buttons">
<button type="button" className="btn btn-primary">Button</button>
<button type="button" className="btn btn-primary">Button</button>
<button type="button" className="btn btn-primary">Button</button>
<button type="button" className="btn btn-primary">Button</button>
<button type="button" className="btn btn-primary">Button</button>
<button type="button" className="btn btn-primary">Button</button>
</div>
}
</div>
)
}
然后在打开关闭时更改状态或以不同方式切换它,在这里你应该为 btn-group-vertical 添加一个类,使整个东西固定在左上角 100% 高度和一些填充或任何你想要的。
为了使列表动态包含一个
this.state.buttons.map(button => { return (<button type="button" className="btn btn-primary">{button}</button>)})
这里有一些本地信息:https://facebook.github.io/react-native/docs/drawerlayoutandroid
render: function() {
var navigationView = (
<View style={{flex: 1, backgroundColor: '#fff'}}>
{
this.state.dynamicTexts.map(dynamicText => { return (
<Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>{]{dynamicText}</Text>
)}
}
</View>
);
return (
<DrawerLayoutAndroid
drawerWidth={300}
drawerPosition={DrawerLayoutAndroid.positions.Left}
renderNavigationView={() => navigationView}>
<View style={{flex: 1, alignItems: 'center'}}>
<Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>Hello</Text>
<Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>World!</Text>
</View>
</DrawerLayoutAndroid>
);
},
方法 openDrawer()
openDrawer();
打开抽屉。
closeDrawer()
closeDrawer();
我相信您可以使用这些组件一起构建它:)
祝你好运!
【讨论】: