[英]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-anonymous
、 src-admin
、 src-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.