Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

大大,代码有两处好像有点小问题 #29

Closed
clevok opened this issue Dec 28, 2018 · 2 comments
Closed

大大,代码有两处好像有点小问题 #29

clevok opened this issue Dec 28, 2018 · 2 comments

Comments

@clevok
Copy link

clevok commented Dec 28, 2018

因为我们的项目是 很多目录层级这样,看之前的issues,似乎不太适合,因此想改改,看代码过程中有几点疑惑

大大 一个是 可能监听了无效事件,根源在redirector.route 方法永远只 emit navigateTo事件
因此在bridge也只emit navigateTo 事件,
因此 option.onNavigate 下 就 dispatcher.on('navigateTo:'+name, onNavigateHandler) 起作用,虽然不影响,因为反正都执行


还有就是 component 下 ,那个name 感觉是 undefined,

function component(def) {
if (!def) {
	// ERROR name is underfined
	console.error(`Illegal component options [${name || 'Anonymous'}]`)
	def = {}
}

component.js 中 bridge.ref(component.getRef) 和 page.js 下bridge.ref(C.getRef) 是不是重复了


message.js 下 assign

  ['on', 'off', 'wait', 'emit', 'assign']

执行到 wait应该是undefined,不晓得,我猜的


还有大大, 下面的代码这种写法看不懂 brideg.js的route

pagepath = (conf.get('customRouteResolve') || conf.get('routeResolve'))(pagepath)
@switer
Copy link
Member

switer commented Dec 30, 2018

感谢反馈

  1. bridge.js里面,有代理跳转方式,里面会派发redirectType + name的消息:
redirectDelegate: function (emitter, dispatcher) {
  ;['navigateTo', 'redirectTo', 'switchTab', 'reLaunch'].forEach(function (k) {
    emitter.on(k, function (url) {
      var name = getPageName(url)
      name && dispatcher.emit(k+':'+name, url, fns.queryParse(url.split('?')[1]))
    })
  })
}
  1. component在微信组原生件化版本之前是需要传name ,升级后对应错误信息没错率,应该去掉
  2. message的wait方式也是遗漏没删除的代码
  3. 框架默认通过 App.config.route 去反射页面路径,获取页面id,这是routeResolve 。有些项目页面目录规则会稍微复杂,所以也提供了自定义的反射方法 App.config.resolvePath,这是customRouteResolve :
A({
  config: {
    route: ['/page/$page', '/pages/$page'],
    resolvePath: function (name) {
      return `/page/${name}`
    }
  }
});

@clevok
Copy link
Author

clevok commented Jan 3, 2019

soga

大大,那个第一点,就是 emitter 他只发出了 navigateTo 事件应该。
redirector.js;

exportee.emit('navigateTo', cfg.url)

然后在page.js 通过 bridge.redirectDelegate(redirector, dispatcher) 转发事件

因为

dispatcher.on('navigateTo:'+name, onNavigateHandler)
	dispatcher.on('redirectTo:'+name, onNavigateHandler)
	dispatcher.on('switchTab:'+name, onNavigateHandler)
	dispatcher.on('reLaunch:'+name, onNavigateHandler)

都执行一个方法,只是没影响,因为并不需要知道他是哪种方法触发

@clevok clevok closed this as completed Jan 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants