omi/packages/omi-ex
张磊 81c5e196b3 update readme 2018-12-09 15:52:03 +08:00
..
src add omi-ex 2018-12-09 15:43:40 +08:00
.gitignore add omi-ex 2018-12-09 15:43:40 +08:00
LICENSE add omi-ex 2018-12-09 15:43:40 +08:00
README.md update readme 2018-12-09 15:52:03 +08:00
package.json add omi-ex 2018-12-09 15:43:40 +08:00
tsconfig.json add omi-ex 2018-12-09 15:43:40 +08:00
tslint.json add omi-ex 2018-12-09 15:43:40 +08:00

README.md

omi-ex

Omi.js ts extension by rainmanhhh

Install

npm i omi-ex

Usage

  • Supports Router/Route(react-router like)
  • Supports keepAlive
  • Sharing data with subcomponents
    • appData.routerData.query
    • appData.routerData.params
    • appData.routerData.data
import {RouterData} from 'omi-ex'

export class AppData {
  abc: string = ''
  passToChild: string = 'from parent'
  routerData: RouterData = new RouterData()
}

export const appData = new AppData()
...
...
render(props: Omi.RenderableProps<AppProps>, data: AppData) {
  return (
    <div>
      <div>
        <a href={'#/'}>home</a>
        <a href={'#/test'}>test</a>
      </div>
      <Router data={appData.routerData}>
        <Route path={'/'} keepAlive={true}><Main/></Route>
        <Route path={'/test'}><Test/></Route>
        <Route path={'*'}>Not found</Route>
      </Router>
    </div>
  )
}
...