From 3052c4d7628d1ff8f9ebf0ec9fe944b7aff207c7 Mon Sep 17 00:00:00 2001 From: guy Date: Sun, 22 Aug 2021 21:20:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/app.js | 40 ++++++++++++++++++++++++---------------- demo/js/center.js | 16 +++++++++++++++- demo/js/main.store.js | 7 ++++++- dist/router.js | 2 +- 4 files changed, 46 insertions(+), 19 deletions(-) diff --git a/demo/app.js b/demo/app.js index f38691b86..c4cdf8dad 100644 --- a/demo/app.js +++ b/demo/app.js @@ -10,26 +10,34 @@ BI.$(function () { var tree = BI.Tree.transformToTreeFormat(Demo.CONFIG); var routes = [{ - path: '/', - component: function(){ + path: "/", + component: function () { return Promise.resolve({ type: "demo.face" - }) + }); } - }]; - - BI.Tree.traversal(tree, function (index, node) { - if (!node.children || BI.isEmptyArray(node.children)) { - routes.push({ - path: '/' + node.text, - component: function(){ - return Promise.resolve({ - type: node.value - }) - } + }, { + name: "component", + path: "/component/:componentId", + component: function () { + return Promise.resolve({ + type: "demo.router" }); } - }); + }]; + + // BI.Tree.traversal(tree, function (index, node) { + // if (!node.children || BI.isEmptyArray(node.children)) { + // routes.push({ + // path: "/", + // component: function () { + // return Promise.resolve({ + // type: node.value + // }); + // } + // }); + // } + // }); // var AppRouter = BI.inherit(BI.Router, obj); // new AppRouter; @@ -49,7 +57,7 @@ BI.$(function () { console.log(_ref); ref = _ref; } - } + }; } }); }); diff --git a/demo/js/center.js b/demo/js/center.js index ca9930550..b7febb6c4 100644 --- a/demo/js/center.js +++ b/demo/js/center.js @@ -9,4 +9,18 @@ Demo.Center = BI.inherit(BI.Widget, { } } }); -BI.shortcut("demo.center", Demo.Center); \ No newline at end of file +BI.shortcut("demo.center", Demo.Center); + +Demo.Router = BI.inherit(BI.Widget, { + props: { + baseCls: "demo-router" + }, + render: function () { + var self = this; + var params = BI.Router.$router.history.current.params; + return { + type: params.componentId + } + } +}); +BI.shortcut("demo.router", Demo.Router); diff --git a/demo/js/main.store.js b/demo/js/main.store.js index f69d33c5f..82d3b81df 100644 --- a/demo/js/main.store.js +++ b/demo/js/main.store.js @@ -44,7 +44,12 @@ handleTreeSelectChange: function (v) { var matched = BI.some(Demo.CONFIG, function (index, item) { if (item.value === v) { - BI.Router.$router.push(item.text); + BI.Router.$router.push({ + name: "component", + params: { + componentId: item.value + } + }); // BI.history.navigate(item.text, {trigger: true}); return true; } diff --git a/dist/router.js b/dist/router.js index 5da02d52f..04c7b5408 100644 --- a/dist/router.js +++ b/dist/router.js @@ -3143,7 +3143,7 @@ created: function () { var self = this, o = this.options; cbs.push(this._callbackListener = function () { - self.tab.setSelect($router.history.current.matched[o.deps].path || "/"); + self.tab.setSelect($router.history.current.fullPath || "/"); }); }, render: function () {