-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from micro-zoe/dev
async rc.4 docs
- Loading branch information
Showing
29 changed files
with
375 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
} | ||
|
||
.page .theme-default-content, | ||
.page-meta { | ||
.page-meta, | ||
.page-nav { | ||
margin-left: 10%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
关闭虚拟路由后,没有了路由隔离后的处理方式会复杂很多,子应用将基于浏览器地址进行渲染,此时需要设置子应用的基础路由。 | ||
native模式下子应用完全基于浏览器路由系统进行渲染,此时需要更加复杂的路由配置,对主应用和子应用的路由都要进行一些改造。 | ||
|
||
#### 路由类型约束 | ||
### 路由类型约束 | ||
native模式下主、子应用需要遵循以下约束: | ||
- 1、主应用是hash路由,子应用也必须是hash路由 | ||
- 2、主应用是history路由,子应用可以是hash或history路由 | ||
|
||
#### 基础路由 | ||
### 基础路由 | ||
**作用:** | ||
|
||
通常主应用和子应用各有一套路由系统,为了防止冲突,主应用需要分配一个路由给子应用,称之为基础路由,子应用可以在这个路由下渲染,但不能超出这个路由的范围,这就是基础路由的作用。 | ||
|
@@ -161,16 +162,8 @@ let app = new Vue({ | |
[email protected]设置base的方式请查看 https://next.router.vuejs.org/ | ||
::: | ||
|
||
## 应用之间跳转 | ||
|
||
[应用之间跳转](/zh/jump) | ||
|
||
## url属性和子应用路由的关系 | ||
答:没有关系! | ||
|
||
micro-app的url属性只是html的地址,它的作用就是加载html资源。 | ||
|
||
#### 子应用不会根据micro-app的url属性渲染对应的页面,而是根据浏览器地址渲染对应的页面。 | ||
### 关于native模式的原理解析 | ||
**子应用不会根据micro-app的url属性渲染对应的页面,而是根据浏览器地址渲染对应的页面。** | ||
|
||
**举个栗子 🌰 :** | ||
|
||
|
@@ -189,7 +182,10 @@ micro-app的url属性只是html的地址,它的作用就是加载html资源。 | |
|
||
**栗子2 🌰 :** | ||
|
||
子应用是hash路由,我们要渲染子应用的page1页面,那么在micro-app的url属性上设置hash值是无效的,`#/page1`应该添加到浏览器地址上。 | ||
场景:子应用是hash路由,我们要渲染子应用的page1页面 | ||
|
||
此时在micro-app的url属性上设置hash值是无效的,`#/page1`应该添加到浏览器地址上。 | ||
|
||
```html | ||
<!-- ❌ 这里的#/page1是无效的,应该添加到浏览器地址上 --> | ||
<micro-app url='http://www.xxx.com/#/page1'></micro-app> | ||
|
@@ -200,7 +196,7 @@ micro-app的url属性只是html的地址,它的作用就是加载html资源。 | |
|
||
**栗子3 🌰 :** | ||
|
||
主应用是history路由,子应用是hash路由,我们要跳转主应用的`my-app`页面,页面中嵌入子应用,我们要展现子应用的`page1`页面。 | ||
场景:主应用是history路由,子应用是hash路由,我们要跳转主应用的`my-app`页面,页面中嵌入子应用,我们要展现子应用的`page1`页面。 | ||
|
||
那么浏览器地址应该为:`域名/my-page#/page1`,我们在主应用中跳转`my-app`页面的参数为:`router.push('/my-page#/page1')` | ||
|
||
|
@@ -214,20 +210,18 @@ micro-app配置如下: | |
|
||
**栗子4 🌰 :** | ||
|
||
主应用是history路由,子应用也是history路由,我们要跳转主应用的`my-app`页面,`my-app`页面中嵌入子应用,我们要展现子应用的`page1`页面。 | ||
场景:主应用是history路由,子应用也是history路由,我们要跳转主应用的`my-app`页面,`my-app`页面中嵌入子应用,我们要展现子应用的`page1`页面。 | ||
|
||
那么浏览器地址应该为:`域名/my-page/page1`,我们在主应用中跳转的参数为:`router.push('/my-page/page1')` | ||
|
||
此时流程为:主应用匹配到`/my-page`路径并渲染`my-app`页面,因为`my-app`页面中嵌入了子应用,此时子应用开始加载并渲染,子应用在渲染时会匹配到`/my-page/page1`并渲染`page1`页面。 | ||
|
||
micro-app配置如下: | ||
|
||
这就是在[快速开始](/zh/start)一章中提到的案例。 | ||
```html | ||
<!-- 子应用通过baseroute设置基础路由,路由 /page1 变为 /my-page/page1 --> | ||
<!-- 子应用通过baseroute设置基础路由/my-page --> | ||
<micro-app url='http://www.xxx.com/index.html' baseroute='/my-page'></micro-app> | ||
``` | ||
|
||
:::tip | ||
如果你看到这里还是无法正确设置路由,那么将主应用设置为history路由,子应用设置为hash路由,可以一劳永逸解决所有问题,此时不需要设置baseroute,也不需要修改主应用和子应用的任何路由设置。 | ||
如果你看到这里还是无法正确设置路由,不妨试试其它路由模式 | ||
::: |
Oops, something went wrong.