简体   繁体   English

如何将 React Native src 应用程序拆分为多个应用程序?

[英]How to split up React Native src application into multiple applications?

Good day!再会!
I'm currently developing a mobile application (on React Native) for an existing web application (frontend built on Vue JS).我目前正在为现有的 web 应用程序(基于 Vue JS 的前端)开发一个移动应用程序(在 React Native 上)。

In web application I have multiple user offices (anonymous user can only login, change site language, and access other primitive features; admin has an office, where he can manage users, make bookings, invoices etc; customer has an access to features that belong only to that user type), and in Vue JS its divided not only on src, but src-anonymous , src-admin , src-customer .在 web 应用程序中,我有多个用户办公室(匿名用户只能登录、更改站点语言和访问其他原始功能;管理员有一个办公室,他可以管理用户、进行预订、发票等;客户可以访问属于仅适用于该用户类型),并且在 Vue JS 中,它不仅在 src 上划分,而且在src-anonymoussrc-adminsrc-customer上划分。

It also contains vue.config.js file, where I set how many pages my application has.它还包含vue.config.js文件,我在其中设置我的应用程序有多少页。 Also web application uses webpack for that purposes. web 应用程序也为此目的使用 webpack。

So how to make this offices split in React Native application for anon, admin and customer?那么如何让这些办公室在 React Native 应用程序中拆分为匿名、管理员和客户呢?

you can add a column in users table such as: user_type and set values ie您可以在用户表中添加一列,例如:user_type 并设置值,即

user_type 0 for Guest, user_type 1 for Admin, user_type 2 for Customer, user_type 0 代表访客,user_type 1 代表管理员,user_type 2 代表客户,

in database.在数据库中。

then on React-Native after fetching response, you can check with condition and navigate to respective Pages.然后在获取响应后在 React-Native 上,您可以检查条件并导航到相应的页面。

if(response.user_type === 0) {
   this.props.navigation("GuestView");
} else if(response.user_type ===1) {
   this.props.navigation.navigate("AdminView")
}

Another way is you can create Components for Specific things,such as a Booking Component which will visible to admin.另一种方法是您可以为特定事物创建组件,例如管理员可以看到的预订组件。 then render them conditionally然后有条件地渲染它们

{ this.props.user_type === 1 && 

<Bookings />

}

with above condition Bookings Component will only be visible to Admin.在上述条件下,预订组件将仅对管理员可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React Native:如何将文件拆分成多个文件并导入它们? - React Native: How to split a file up into multiple files and import them? 如何在React Native中将包含多个符号的文本拆分为数组? - How to split text contain multiple symbol into an array in react native? 如何在反应中将单个组件代码拆分为多个文件 - How to split up single component code into multiple files in react 如何将庞大的React应用程序拆分为多个小模块 - How to split a mammoth React application into multiple small modules 如何在共享代码的同时使用每个应用程序不同的配置来管理本机应用程序的多重反应? - How to manage multiply react native applications using different configuration per application, while sharing code? 如何从 React Native 的字符串中提取 img src? - How do I extract img src from a string in React Native? Highcharts-如何在Rails 3中拆分多个图表 - Highcharts - How to split up multiple charts in Rails 3 如何正确拆分React应用程序组件 - How to proper split React application components 如何在 React Native 中设置 redux? - How to set up redux in react native? React-Native在用户注册后重新启动应用程序 - React-native restart an application on user sign up
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM