Skip to content

Commit b48ad9c

Browse files
committed
docs: rEADME 修改
affects: @vue-async/module-loader
1 parent 00ed84f commit b48ad9c

File tree

4 files changed

+39
-20
lines changed

4 files changed

+39
-20
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,6 @@ sw.*
8888

8989
# Vim swap files
9090
*.swp
91+
92+
# Lerna changelog cache files
93+
.changelog/

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11

2+
## independent (2020-12-15)
3+
4+
#### :rocket: New Feature
5+
* `module-loader-typing`, `module-loader`, `resource-manager`, `utils`
6+
* [#4](https://github.com/aceHubert/vue-async/pull/4) 添加模块服务端渲染 ([@aceHubert](https://github.com/aceHubert))
7+
8+
#### Committers: 1
9+
- Hubert X. ([@aceHubert](https://github.com/aceHubert))
10+
11+
12+
213

314

415

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
# @vue-async
1+
# Vue 模块化加载
2+
3+
[文档说明](./packages/module-loader/README.md)

packages/module-loader/README.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
# @vue-async/module-loader
2-
3-
从远程地址链接加载`模块`.
4-
<br>
1+
# 模块化加载
52

63
```js
74
// ## 主程序 ##
85

96
// 引入模块
107
import ModuleLoader from '@vue-async/module-loader';
118

9+
/*
10+
* 注意:ES Module需要添加到`transpile`中编译
11+
* vue-cli 请添加到 vue.config.js 中的 transpileDependencies 上
12+
* nuxtjs 请添加到 nuxt.config.js 中的 build.transpile 上
13+
*/
14+
1215
Vue.use(ModuleLoader);
1316

1417
// 方法一
@@ -23,10 +26,10 @@ app.$moduleLoader(ModuleConfig).then(()=>{
2326
app.$mount('#app')
2427
})
2528

26-
// 方法二 (例如在 nuxtjs 的 plugin 中使用时)
29+
// 方法二 ( nuxtjs 的 plugin 中使用时)
2730
var plugin = (context) => {
2831
// 这里需要手动注册 dynamicComponent,
29-
// 子模块中才可以能过 this.$dynamicComponent.add()方法
32+
// 子模块中才可以能过 this.$dynamicComponent.add()等方法
3033
var moduleLoader =
3134
new ModuleLoader({}).registerDynamicComponent(context.store);
3235

@@ -36,21 +39,21 @@ var plugin = (context) => {
3639
context.app.moduleLoader = moduleLoader
3740
}
3841
export default plugin
42+
3943
```
4044
``` js
4145
// ## 子模块 ##
42-
// index.js 入口文件
46+
47+
// main.js 入口文件
4348
export default function(Vue, options){}
4449

4550
// Typescript
4651
import { VueConstructor } from 'vue';
4752
import { ModuleContext } from '@vue-async/module-loader-typing';
4853

49-
// 方法一调用方式
50-
export default function(this:InstanceType<VueConstructor>, Vue:VueConstructor, options: Recode<string, any> ={}){}
51-
52-
// 方法二调用方式
53-
export default function(this:ModuleContext, Vue:VueConstructor, options: Recode<string, any> ={}){}
54+
export default function(Vue:VueConstructor, options: Recode<string, any> ={}){
55+
// do something
56+
}
5457
```
5558

5659
## ModuleConfig 模块配置
@@ -63,18 +66,18 @@ export default function(this:ModuleContext, Vue:VueConstructor, options: Recode<
6366
{
6467
// 模块名称:远程 umd 文件 url 地址
6568
moduleName: 'remote url',
66-
//
6769
moduleName: {
6870
entry: 'remote url', // 远程 umd 文件 url 地址
69-
styles: [],
71+
styles: [], // 自定义样式文件(例如 ExtractTextPlugin extract:true时打成独立 css文件)
7072
args:{}
7173
}
7274
},
7375
// Object
7476
{
7577
moduleName: '',
7678
entry: '',
77-
styles:[]
79+
styles:[],
80+
args:{}
7881
},
7982
// Function
8083
function entry(Vue){}
@@ -110,7 +113,7 @@ Type: `Object`
110113
此参数与 `$moduleLoaderManager` 区别在于此参数只会传递给单个子模块调用
111114
<br>
112115

113-
## 子模块上下文方法
116+
## 模块上下文注入方法
114117
`this.$componentLoader(remote url)`
115118
远程加载单个组件,返回 `Promise<VueComponent>`, 可作为 Vue 异步组件直接加载。
116119
<br>
@@ -129,7 +132,7 @@ Type: `Object`
129132
`this.$dynamicComponent`
130133
子模块注册动态组件到主程序 `store` namespace `dynamicComponent`
131134
当使用方法一在 `new Vue({})` 之后调用时,如果引用了 `vuex` 将会自动注入此方法
132-
当使用方法二在之前调用时,需要手动 `registerDynamicComponent(store)` 之后才可以被调用
135+
当使用方法二在 Vue 实例之前调用时,需要手动 `registerDynamicComponent(store)` 之后才可以被调用
133136

134137
&nbsp;&nbsp;&nbsp; 方法:
135138
&nbsp;&nbsp;&nbsp; `add(component, position)` 添加组件到指定的位置
@@ -153,13 +156,13 @@ Type: `Object`
153156
`addRoutes(routes:RouteConfig[])`
154157
添加路由, 主程序需要引用`vue-router`, 此方法可以在实例化参数中被覆盖重写
155158

156-
注:当主组件引用`vue-router`包后,将会自动注入方法解决404问题,需要在主程序中添加一条配置 `name``404` `page-not-found` `not-found``path``*` 的路由后生效
159+
##### <font color="red">注:当主组件引用`vue-router`包后,将会自动注入方法解决404问题,需要在主程序中添加一条配置 `name``404` `page-not-found` `not-found``path``*` 的路由后生效</font>
157160

158161
<br>
159162
<br>
160163
<br>
161164

162-
## <font color="red">问题</font>
165+
## <font color="red">其它问题</font>
163166
1、webpack 打包 Can't resolve "module"
164167
``` json
165168
{

0 commit comments

Comments
 (0)