feat:navigator add extra

This commit is contained in:
pengfei.zhou 2019-12-09 20:33:52 +08:00
parent f6ec519202
commit 38eb880465
2 changed files with 14 additions and 5 deletions

View File

@ -17,9 +17,16 @@ import { BridgeContext } from "../runtime/global"
export function navigator(context: BridgeContext) {
return {
push: (scheme: string, alias: string, animated = true) => {
push: (scheme: string, config?: {
alias?: string,
animated?: boolean,
extra?: object,
}) => {
if (config && config.extra) {
(config as any).extra = JSON.stringify(config.extra)
}
return context.navigator.push({
scheme, alias, animated
scheme, config
})
},
pop: (animated = true) => {

View File

@ -42,7 +42,7 @@ export abstract class Panel {
abstract build(rootView: Group): void
private __data__: any
private __data__?: object
private __root__ = new Root
private headviews: Map<string, View> = new Map
@ -73,8 +73,10 @@ export abstract class Panel {
}
@NativeCall
private __init__(frame: Frame, data: any) {
this.__data__ = data
private __init__(frame: Frame, data?: string) {
if (data) {
this.__data__ = JSON.parse(data)
}
this.__root__.width = frame.width
this.__root__.height = frame.height
this.__root__.children.length = 0