美文网首页
RN使用JS和TS持续总结

RN使用JS和TS持续总结

作者: 羽化行云 | 来源:发表于2021-02-06 09:56 被阅读0次

1.JS项目结构
|——class1
|——|——actor
|——|——|——action.js
|——|——component
|——|——|——connect.tsx
|——|——|——item.js
|——|——|——top.js
|——|——img
|——|——index.js
|——|——store.js
|——|——webapi.js
|——class2

actor:定义默认属性值和设置值
component:包含各种UI组件
img:当前类的图片
index.js:默认进入的UI界面
store.js:各种点击事件,并处理掉用网络请求
webapi.js:网络请求

2.TS项目结构
|——class1
|——|——actions
|——|——|——actions.ts
|——|——|——index.ts
|——|——components
|——|——|——connect.tsx
|——|——|——item.tsx
|——|——|——top.tsx
|——|——img
|——|——reducers
|——|——|——main.ts
|——|——constant.ts
|——|——index.ts
|——|——selectors.ts
|——|——types.ts
|——class2

此项目结构使用Redux
actions:index.ts 初始化和网络请求;actions.ts各种点击事件和网络请求
components:包含各种UI组件
img:当前类的图片
reducers:main.ts修改数据方法
index.tsx:默认进入的UI界面
selectors.ts:定义链接器
types.ts:定义属性值

3.es6页面跳转传值

//传值
msg.emit('router: goToNext', {routeName: 'ArticleList',cateId: cateId})
//取值
const { state } = this.props.navigation;

相关文章

网友评论

      本文标题:RN使用JS和TS持续总结

      本文链接:https://www.haomeiwen.com/subject/irintltx.html