Browse Source

Pull request #2753: 无JIRA任务,去掉路由里的nextTick

Merge in VISUAL/fineui from ~GUYI/fineui:master to master

* commit '3a06fccf97a91350b5c0de7cc588b920a881c909':
  无jira任务,多提交了
  Revert "无JIRA任务 路由问题"
es6
Guyi 3 years ago
parent
commit
653e6b20b5
  1. 35
      src/router/router.js

35
src/router/router.js

@ -3156,27 +3156,24 @@
}, },
created: function () { created: function () {
var self = this, o = this.options; var self = this, o = this.options;
// 嵌套路由 + single 下父亲执行setSelect后会执行一遍push + _callbackListener,之后在cbs.forEach下会执行到刚push进去的_callbackListener导致执行两次,这里加一个nextTick让forEach走不到新push进去的方法。 cbs.push(this._callbackListener = function () {
BI.nextTick(function () { var current = $router.history.current;
cbs.push(self._callbackListener = function () { // 匹配的路径名(/component/:id)
var current = $router.history.current; var matchedPath = current.matched[o.deps] && current.matched[o.deps].path;
// 匹配的路径名(/component/:id) var component = current.matched[o.deps] && current.matched[o.deps].components[o.name];
var matchedPath = current.matched[o.deps] && current.matched[o.deps].path;
var component = current.matched[o.deps] && current.matched[o.deps].components[o.name]; if (BI.isNotNull(component)) {
if (matchedPath) {
if (BI.isNotNull(component)) { BI.each(current.params, function (key, value) {
if (matchedPath) { // 把 :id 替换成具体的值(/component/demo.td)
BI.each(current.params, function (key, value) { matchedPath = matchedPath.replace(`:${key}`, value);
// 把 :id 替换成具体的值(/component/demo.td) });
matchedPath = matchedPath.replace(`:${key}`, value);
});
}
self.tab.setSelect(matchedPath || "/");
} }
}); self.tab.setSelect(matchedPath || "/");
// "bi.router_view"是由"bi.tab"实现的,cardCreator是一个异步过程,在"bi.router_view"创建之前,cbs里不会有创建子组件的方法,在初始化路由时,没法直接渲染到子组件,所以这里手动加了一次调用 }
self._callbackListener();
}); });
// "bi.router_view"是由"bi.tab"实现的,cardCreator是一个异步过程,在"bi.router_view"创建之前,cbs里不会有创建子组件的方法,在初始化路由时,没法直接渲染到子组件,所以这里手动加了一次调用
this._callbackListener();
}, },
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;

Loading…
Cancel
Save