Skip to content

Commit c62cd75

Browse files
author
Ken Berkeley
committed
bak
1 parent 012b63f commit c62cd75

File tree

4 files changed

+56
-15
lines changed

4 files changed

+56
-15
lines changed

docs/zh-cn/Getting-started.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
* [Vue.js 1.x Guide](http://v1.vuejs.org/guide/)
88
* [Vue.js 1.x API](http://v1.vuejs.org/api/)
9-
* [`vue-router` docs for Vue 1.x](https://github.com/vuejs/vue-router/tree/1.0/docs/zh-cn)
9+
* [Vue Router docs for Vue 1.x](https://github.com/vuejs/vue-router/tree/1.0/docs/zh-cn)
1010

1111
同时,您还需要熟悉 ES6。例如,请把如下代码转译成 ES5:
1212
```
@@ -18,16 +18,18 @@ const foo = ({ hello: { world: bar } }) => ({ bar })
1818
## ⊙ 安装
1919

2020
> **强烈建议**升级到 `node ≥ 6.x / npm ≥ 3.x` 环境
21-
> **强烈推荐**往后使用 `cnpm` 替代 `npm` 安装 pacakge
22-
> (运行 `npm set registry https://registry.npm.taobao.org` 换源,并不能解决 `node-sass` 的二进制源码包下载极慢的问题)
21+
> **强烈推荐**往后使用 `cnpm` 替代 `npm` 安装依赖
22+
>
23+
> 运行 `npm set registry https://registry.npm.taobao.org` 换源
24+
> 并不能解决 `node-sass` 的二进制源码包下载极慢的问题
2325
2426
```
25-
$ npm i cnpm -g // 全局安装 cnpm
27+
$ npm i cnpm -g // 全局安装 cnpm
2628
$ cnpm i cross-env -g // 全局安装 跨平台环境变量配置器
2729
2830
$ git clone https://github.com/kenberkeley/vue-demo.git
2931
$ cd vue-demo
30-
$ cnpm i // 安装本项目依赖
32+
$ cnpm i // 安装本项目依赖
3133
```
3234

3335
## ⊙ 命令

docs/zh-cn/Structure.md

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
│ ├── filters/ # 过滤器(FILTER)
1111
│ ├── mixins/ # (MIXIN)
1212
│ ├── routes/ # 路由(ROUTE)
13-
│ ├── services/ # 服务(SERVICE)
13+
│ ├── services/ # 服务(SERVICE,统一管理 XHR 请求
1414
│ ├── utils/ # 工具类(UTIL)
1515
│ ├── views/ # 路由页面组件(VIEW)
1616
│ ├── app.js # 启动文件
@@ -24,7 +24,46 @@
2424
```
2525

2626
您可以根据业务需求改动目录结构
27-
例如本 demo 就在根目录下新增了 `docs/`(文档)与 `mock/`(Mock 服务器)
27+
譬如本 demo 就在根目录下新增了 `docs/`(文档)与 `mock/`(Mock 服务器)
2828

29-
从表面上看,本 demo 与 [`vue-cli`](https://github.com/vuejs/vue-cli) 生成的[结构](http://vuejs-templates.github.io/webpack/structure.html)并没有太大差异
30-
但接下来的文档内容,会让您了解到更深入的设计
29+
上述目录结构中,需要注意的是 `src/components/``src/views/` 的区别
30+
不妨把本 demo 中的这两个目录以树状形式展开:
31+
32+
```
33+
src/components/ # 组件
34+
├── App.vue # 根组件
35+
├── Breadcrumb.vue # 面包屑
36+
├── Navbar.vue # 顶部导航栏
37+
├── Pagination.vue # 分页
38+
├── Select/ # 下拉框选择框组件
39+
│   ├── LimitSelect.vue # “每页显示多少条记录” 下拉选择框
40+
│   └── Select2.vue # 对 Select2 的封装
41+
└── Sidebar/ # 侧边栏组件
42+
├── index.vue # 侧边栏
43+
└── Link.vue # 导航链接封装
44+
45+
src/views/ # 路由页面组件
46+
├── index.vue # 首页
47+
├── auth/ # 用户认证模块
48+
│   ├── login.vue # 登录页
49+
│   └── logout.vue # 注销登录页
50+
└── msg/ # 留言板模块
51+
├── index.vue # /msg(留言板首页,alias => /msg/list)
52+
├── list.vue # /msg/list(留言板列表)
53+
├── add.vue # /msg/add(新增留言)
54+
├── detail.vue # /msg/detail/:msgId(查看留言)
55+
├── update.vue # /msg/update/:msgId(修改留言)
56+
├── _components/ # 留言板模块共用组件
57+
│   ├── AuthorSelect.vue # 留言发布者选择下拉框
58+
│   ├── MsgForm.vue # 留言表单
59+
│   └── OptBtnGroup.vue # 留言操作按钮组
60+
└── _mixins/ # 留言板模块共用 mixins
61+
   └── autoLoadByParams.js # 根据 $route.params.msgId 自动加载
62+
```
63+
64+
根据注释,我们大概知道了二者的差别:
65+
66+
`src/components/`
67+
* 主要是全局性的,或通用性很强的组件(例如是对某些插件的封装)
68+
* 一般不会涉及到业务逻辑
69+
* 具备良好的封装性(根组件 `App.vue` 除外)
File renamed without changes.

src/components/Sidebar/index.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@
1010
<span class="caret"></span>
1111
</a>
1212
<div :id="'panel'+$index" class="collapse w-90p m-0-auto">
13-
<vlink v-for="subRoute in route.subRoutes"
13+
<link v-for="subRoute in route.subRoutes"
1414
:path="subRoute.fullPath"
1515
:title="subRoute.title"
1616
:icon="subRoute.icon">
17-
</vlink>
17+
</link>
1818
</div><!-- .collapse -->
1919
</div><!-- v-if -->
20-
<vlink v-else
20+
<link v-else
2121
:path="route.path"
2222
:title="route.title"
2323
:icon="route.icon"
2424
:is-exact="true">
25-
</vlink>
25+
</link>
2626
</template>
2727
</div><!-- #sidebar -->
2828
</template>
2929
<script>
30-
import Vlink from './Vlink'
30+
import Link from './Link'
3131
import routesMap from 'ROUTE/map/'
3232
import _pickBy from 'lodash/pickBy'
3333
3434
export default {
35-
components: { Vlink },
35+
components: { Link },
3636
computed: {
3737
routes: () => _pickBy(routesMap, route => route.showInSidebar)
3838
},

0 commit comments

Comments
 (0)