20.0b84e47a.js
26.1 KB
(window.webpackJsonp=window.webpackJsonp||[]).push([[20],{301:function(s,t,a){"use strict";a.r(t);var n=a(4),e=Object(n.a)({},function(){var s=this,t=s.$createElement,a=s._self._c||t;return a("ContentSlotsDistributor",{attrs:{"slot-key":s.$parent.slotKey}},[a("h1",{attrs:{id:"开发规范"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#开发规范","aria-hidden":"true"}},[s._v("#")]),s._v(" 开发规范")]),s._v(" "),a("p",[s._v("编码规范好比协议,有了 "),a("code",[s._v("Http")]),s._v("、"),a("code",[s._v("TCP")]),s._v(" 等各种协议,计算机之间才能有效地通信,同样的,有了一致的编码规范,开发人员之间才能有效地合作")]),s._v(" "),a("p",[s._v("为提高软件开发质量,降低开发周期,增强代码的可重用性和易读性,使软件便于维护及移交,开发人员间便于交流和协作,本规范适用于前端团队,以作参考。")]),s._v(" "),a("div",{staticClass:"custom-block danger"},[a("p",{staticClass:"custom-block-title"},[s._v("注意")]),s._v(" "),a("p",[s._v("开发规范执行情况将会不定期进行 "),a("strong",[s._v("Code Review")]),s._v(",不符合规范的内容必须进行整改。")])]),s._v(" "),a("h2",{attrs:{id:"vscode-插件"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#vscode-插件","aria-hidden":"true"}},[s._v("#")]),s._v(" VSCode 插件")]),s._v(" "),a("p",[s._v("为了使开发过程控制,错误提醒以及语法规范在代码编写过程中得到有效提醒及控制,要求使用 "),a("strong",[s._v("VSCode")]),s._v(" 必须安装以下插件")]),s._v(" "),a("ul",[a("li",[s._v("ESLint")]),s._v(" "),a("li",[s._v("HTML Snippets")]),s._v(" "),a("li",[s._v("IntelliSense for CSS class names in HTML")]),s._v(" "),a("li",[s._v("JavaScript (ES6) code snippets")]),s._v(" "),a("li",[s._v("JavaScript standardjs styled snippets")]),s._v(" "),a("li",[s._v("language-stylus")]),s._v(" "),a("li",[s._v("npm")]),s._v(" "),a("li",[s._v("npm Intellisense")]),s._v(" "),a("li",[s._v("Prettier - Code formatter")]),s._v(" "),a("li",[s._v("Sass")]),s._v(" "),a("li",[s._v("StandardJS - JavaScript Standard Style")]),s._v(" "),a("li",[s._v("Todo Tree")]),s._v(" "),a("li",[s._v("Vetur")]),s._v(" "),a("li",[s._v("Vue 2 Snippets")])]),s._v(" "),a("h2",{attrs:{id:"文件与目录命名规范"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#文件与目录命名规范","aria-hidden":"true"}},[s._v("#")]),s._v(" 文件与目录命名规范")]),s._v(" "),a("p",[s._v("前端开发规范应用于 Web 网站、管理平台、移动端内嵌、微信小程序等范围,即使是本文档项目("),a("code",[s._v("doc-press")]),s._v(")中的文件命名,依然建议应用本规范")]),s._v(" "),a("p",[s._v("命名规范优秀的行业范例可参考 "),a("a",{attrs:{href:"https://github.com/vuejs/vue",target:"_blank",rel:"noopener noreferrer"}},[s._v("Vuejs"),a("OutboundLink")],1),s._v(" 和 "),a("a",{attrs:{href:"https://github.com/facebook/react",target:"_blank",rel:"noopener noreferrer"}},[s._v("Reactjs"),a("OutboundLink")],1),s._v(" 的源码")]),s._v(" "),a("h3",{attrs:{id:"目录命名"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#目录命名","aria-hidden":"true"}},[s._v("#")]),s._v(" 目录命名")]),s._v(" "),a("p",[s._v("业务功能结构示例")]),s._v(" "),a("div",{staticClass:"language-js line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-js"}},[a("code",[s._v("├─用户管理\n └─授权管理\n ├─角色管理\n └─用户角色绑定\n")])]),s._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[s._v("1")]),a("br"),a("span",{staticClass:"line-number"},[s._v("2")]),a("br"),a("span",{staticClass:"line-number"},[s._v("3")]),a("br"),a("span",{staticClass:"line-number"},[s._v("4")]),a("br")])]),a("p",[s._v("目录命名示例")]),s._v(" "),a("div",{staticClass:"language-js line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-js"}},[a("code",[s._v("✖\n├─userManage\n └─userAuthManage\n ├─RoleManage\n └─userRoleBind\n\n✔\n├─user\n └─auth\n ├─role\n └─user"),a("span",{pre:!0,attrs:{class:"token operator"}},[s._v("-")]),s._v("role\n")])]),s._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[s._v("1")]),a("br"),a("span",{staticClass:"line-number"},[s._v("2")]),a("br"),a("span",{staticClass:"line-number"},[s._v("3")]),a("br"),a("span",{staticClass:"line-number"},[s._v("4")]),a("br"),a("span",{staticClass:"line-number"},[s._v("5")]),a("br"),a("span",{staticClass:"line-number"},[s._v("6")]),a("br"),a("span",{staticClass:"line-number"},[s._v("7")]),a("br"),a("span",{staticClass:"line-number"},[s._v("8")]),a("br"),a("span",{staticClass:"line-number"},[s._v("9")]),a("br"),a("span",{staticClass:"line-number"},[s._v("10")]),a("br"),a("span",{staticClass:"line-number"},[s._v("11")]),a("br")])]),a("p",[s._v("目录的命名,应尽可能结合上下、父子结构进行上下文信息描述,目录名自身应尽可能简洁直观。文本上使用全小写字母,有词组的情况使用 “-” 符号隔开")]),s._v(" "),a("h4",{attrs:{id:"为什么要使用小写?"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#为什么要使用小写?","aria-hidden":"true"}},[s._v("#")]),s._v(" 为什么要使用小写?")]),s._v(" "),a("ul",[a("li",[a("p",[s._v("易用性/可读性"),a("br"),s._v("\n小写文件名通常比大写文件名更易读,比如 "),a("code",[s._v("accessibility.txt")]),s._v(" 就比 "),a("code",[s._v("ACCESSIBILITY.TXT")]),s._v(" 易读。即使使用驼峰命名法,如 "),a("code",[s._v("UserRoleBind")]),s._v(" 或 "),a("code",[s._v("userRoleBind")]),s._v(" 不如 "),a("code",[s._v("user-role-bind")]),s._v(" 的可读性高")])]),s._v(" "),a("li",[a("p",[s._v("兼容性"),a("br"),s._v("\n不同操作系统对于大小兼容程度不一样,为了保证编译、部署后的内容在所有平台上顺利部署,目录名也应当使用小写")])]),s._v(" "),a("li",[a("p",[s._v("行业惯例"),a("br"),s._v("\n诸如 "),a("code",[s._v("Java")]),s._v("、"),a("code",[s._v(".net")]),s._v("、"),a("code",[s._v("C")]),s._v(" 等著名语言的包路径均为小写,行业巨头的良好规范也逐渐成为行业里约定俗成的规范")])])]),s._v(" "),a("h3",{attrs:{id:"文件命名"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#文件命名","aria-hidden":"true"}},[s._v("#")]),s._v(" 文件命名")]),s._v(" "),a("p",[s._v("文件名的规则在遵循目录命名的规则作为基础规则,但文件名的命名规则相比目录,略有不同")]),s._v(" "),a("h4",{attrs:{id:"插件-组件-页面"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#插件-组件-页面","aria-hidden":"true"}},[s._v("#")]),s._v(" 插件/组件/页面")]),s._v(" "),a("p",[s._v("单文件组件、插件/组件主体、页面的文件名应该始终是单词大写开头 (PascalCase)")]),s._v(" "),a("p",[s._v("单词大写开头对于代码编辑器的自动补全最为友好,因为这使得我们在 JS(X) 和模板中引用组件的方式尽可能的一致。然而,混用文件命名方式有的时候会导致大小写不敏感的文件系统的问题。")]),s._v(" "),a("p",[a("strong",[s._v("Vuejs")]),s._v(" 官方文档中,对于文件命名也有相应的 "),a("a",{attrs:{href:"https://cn.vuejs.org/v2/style-guide/#%E5%8D%95%E6%96%87%E4%BB%B6%E7%BB%84%E4%BB%B6%E6%96%87%E4%BB%B6%E7%9A%84%E5%A4%A7%E5%B0%8F%E5%86%99-%E5%BC%BA%E7%83%88%E6%8E%A8%E8%8D%90",target:"_blank",rel:"noopener noreferrer"}},[s._v("指导规范"),a("OutboundLink")],1)]),s._v(" "),a("p",[s._v("文件命名示例")]),s._v(" "),a("div",{staticClass:"language-js line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-js"}},[a("code",[s._v("✖\ncomponents\n └─grid\n ├─grid"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("sass\n ├─headRow"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("vue\n ├─bodyrow"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("vue\n ├─grid"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("vue\n └─index"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("js\n\n✔\ncomponents\n └─grid\n ├─grid"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("sass\n ├─HeadRow"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("vue\n ├─BodyRow"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("vue\n ├─Grid"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("vue\n └─index"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(".")]),s._v("js\n")])]),s._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[s._v("1")]),a("br"),a("span",{staticClass:"line-number"},[s._v("2")]),a("br"),a("span",{staticClass:"line-number"},[s._v("3")]),a("br"),a("span",{staticClass:"line-number"},[s._v("4")]),a("br"),a("span",{staticClass:"line-number"},[s._v("5")]),a("br"),a("span",{staticClass:"line-number"},[s._v("6")]),a("br"),a("span",{staticClass:"line-number"},[s._v("7")]),a("br"),a("span",{staticClass:"line-number"},[s._v("8")]),a("br"),a("span",{staticClass:"line-number"},[s._v("9")]),a("br"),a("span",{staticClass:"line-number"},[s._v("10")]),a("br"),a("span",{staticClass:"line-number"},[s._v("11")]),a("br"),a("span",{staticClass:"line-number"},[s._v("12")]),a("br"),a("span",{staticClass:"line-number"},[s._v("13")]),a("br"),a("span",{staticClass:"line-number"},[s._v("14")]),a("br"),a("span",{staticClass:"line-number"},[s._v("15")]),a("br"),a("span",{staticClass:"line-number"},[s._v("16")]),a("br"),a("span",{staticClass:"line-number"},[s._v("17")]),a("br")])]),a("h2",{attrs:{id:"css-样式预处理"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#css-样式预处理","aria-hidden":"true"}},[s._v("#")]),s._v(" CSS 样式预处理")]),s._v(" "),a("p",[s._v("对于 CSS 样式预处理方案,比较流行的有 "),a("code",[s._v("SASS/SCSS")]),s._v("、"),a("code",[s._v("LESS")]),s._v(" 和 "),a("code",[s._v("Stylus")]),s._v(",大体上的使用方式类似,区别在于功能的多少与扩展的能力。")]),s._v(" "),a("p",[s._v("综合各方面考虑,开发规范如下(微信小程序不在讨论范围)")]),s._v(" "),a("ul",[a("li",[s._v("前端项目统一使用 "),a("code",[s._v("SASS/SCSS")]),s._v(" 开发样式预处理内容")]),s._v(" "),a("li",[a("code",[s._v("web-open-platform")]),s._v(" 项目使用 "),a("code",[s._v("Stylus")])])]),s._v(" "),a("p",[s._v("关于文件及目录的命名遵循 "),a("a",{attrs:{href:"#%E6%96%87%E4%BB%B6%E4%B8%8E%E7%9B%AE%E5%BD%95%E5%91%BD%E5%90%8D%E8%A7%84%E8%8C%83"}},[s._v("文件与目录命名")]),s._v(" 规则")]),s._v(" "),a("h3",{attrs:{id:"class-命名"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#class-命名","aria-hidden":"true"}},[s._v("#")]),s._v(" class 命名")]),s._v(" "),a("p",[s._v('对于 class name 的命名同样遵循全小写与单词间使用 "-" 隔开原则')]),s._v(" "),a("p",[s._v("命名示例")]),s._v(" "),a("div",{staticClass:"language-scss line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-scss"}},[a("code",[a("span",{pre:!0,attrs:{class:"token selector"}},[s._v(".user-container ")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token selector"}},[s._v("width: 100vw\n .user-header ")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token property"}},[s._v("background-color")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" #eee\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),s._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),s._v("\n")])]),s._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[s._v("1")]),a("br"),a("span",{staticClass:"line-number"},[s._v("2")]),a("br"),a("span",{staticClass:"line-number"},[s._v("3")]),a("br"),a("span",{staticClass:"line-number"},[s._v("4")]),a("br"),a("span",{staticClass:"line-number"},[s._v("5")]),a("br"),a("span",{staticClass:"line-number"},[s._v("6")]),a("br")])]),a("h3",{attrs:{id:"样式抽象"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#样式抽象","aria-hidden":"true"}},[s._v("#")]),s._v(" 样式抽象")]),s._v(" "),a("p",[s._v("一个工程通常会有大量的页面、组件和插件,功能虽不同,但风格必须统一。对于主题风格部分的内容,必须提取到专用样式文件中进行维护。类似的功能或结构的样式内容在多处独立维护,是冗余且低效的,多人协同开发时须杜绝该现象发生,在进行样式定义之前应互相询问是否存在重复定义的情况。")]),s._v(" "),a("p",[a("strong",[s._v("BTW")]),a("br"),s._v("\nCSS 样式预处理,只使用最基本的结构嵌套功能是不够的,了解和使用高级特性才是提高效率和效果的最佳实践")]),s._v(" "),a("h2",{attrs:{id:"路由命名规则"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#路由命名规则","aria-hidden":"true"}},[s._v("#")]),s._v(" 路由命名规则")]),s._v(" "),a("p",[s._v("在路由(Vue Router)的命名中,依然遵循 "),a("a",{attrs:{href:"#%E6%96%87%E4%BB%B6%E4%B8%8E%E7%9B%AE%E5%BD%95%E5%91%BD%E5%90%8D%E8%A7%84%E8%8C%83"}},[s._v("文件与目录命名")]),s._v(" 规则;因为路由命名的结果最终会体现在浏览器的地址栏中,所以在路由的命名过程中依然是推荐结合业务结构的上下文级进行组合命名,内容必须做到精简、简洁,不要让最终呈现出来的地址链接过于冗长。")]),s._v(" "),a("p",[s._v("一个网站的路由结构通常两层就可以完全满足需求,所以除去页面布局结构外,大量的业务页面的路由均为同级,既然是同级,就需要通过路由的路径(path)来声明功能的业务结构")]),s._v(" "),a("p",[s._v("业务功能结构示例")]),s._v(" "),a("div",{staticClass:"language-js line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-js"}},[a("code",[s._v("├─系统管理\n └─用户管理\n └─角色授权管理\n")])]),s._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[s._v("1")]),a("br"),a("span",{staticClass:"line-number"},[s._v("2")]),a("br"),a("span",{staticClass:"line-number"},[s._v("3")]),a("br")])]),a("p",[s._v("路由命名示例")]),s._v(" "),a("div",{staticClass:"language-js line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-js"}},[a("code",[s._v("✖\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v(" path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/systemManage/userManage/roleAuth'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),s._v("\n\n✔\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v(" path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/system/user/role-auth'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),s._v("\n")])]),s._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[s._v("1")]),a("br"),a("span",{staticClass:"line-number"},[s._v("2")]),a("br"),a("span",{staticClass:"line-number"},[s._v("3")]),a("br"),a("span",{staticClass:"line-number"},[s._v("4")]),a("br"),a("span",{staticClass:"line-number"},[s._v("5")]),a("br")])]),a("p",[a("strong",[s._v("现有项目命名情况改造实例")])]),s._v(" "),a("p",[s._v("以现有素+管理平台的路由设置情况进行举例")]),s._v(" "),a("div",{staticClass:"language-js line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-js"}},[a("code",[s._v("✖ 不推荐\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("[")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v(" path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/workbench/stockManager/stockType'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("// 存货类别")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v(" path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/workbench/stockManager/goodsClassify'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("// 存货分类")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v(" path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/workbench/stockManager/goodsSeries'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("// 存货系列")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v(" path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/workbench/stockManager/goodsUnit'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("// 计量组单位")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v(" path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/workbench/stockManager/stockBrands'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("// 存货品牌")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v(" path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/workbench/stockManager/stockForm'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("// 存货形态")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v(" path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/workbench/stockManager/stockArchives'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("// 存货档案")]),s._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("]")]),s._v("\n\n✔ 推荐设置\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("[")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v(" path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/workbench/stock/type'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("// 存货类别")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v(" path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/workbench/stock/category'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("// 存货分类")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v(" path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/workbench/stock/series'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("// 存货系列")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v(" path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/workbench/stock/goods-unit'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("// 计量组单位")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v(" path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/workbench/stock/brand'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("// 存货品牌")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v(" path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/workbench/stock/form'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("// 存货形态")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v(" path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/workbench/stock/file'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("// 存货档案")]),s._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("]")]),s._v("\n")])]),s._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[s._v("1")]),a("br"),a("span",{staticClass:"line-number"},[s._v("2")]),a("br"),a("span",{staticClass:"line-number"},[s._v("3")]),a("br"),a("span",{staticClass:"line-number"},[s._v("4")]),a("br"),a("span",{staticClass:"line-number"},[s._v("5")]),a("br"),a("span",{staticClass:"line-number"},[s._v("6")]),a("br"),a("span",{staticClass:"line-number"},[s._v("7")]),a("br"),a("span",{staticClass:"line-number"},[s._v("8")]),a("br"),a("span",{staticClass:"line-number"},[s._v("9")]),a("br"),a("span",{staticClass:"line-number"},[s._v("10")]),a("br"),a("span",{staticClass:"line-number"},[s._v("11")]),a("br"),a("span",{staticClass:"line-number"},[s._v("12")]),a("br"),a("span",{staticClass:"line-number"},[s._v("13")]),a("br"),a("span",{staticClass:"line-number"},[s._v("14")]),a("br"),a("span",{staticClass:"line-number"},[s._v("15")]),a("br"),a("span",{staticClass:"line-number"},[s._v("16")]),a("br"),a("span",{staticClass:"line-number"},[s._v("17")]),a("br"),a("span",{staticClass:"line-number"},[s._v("18")]),a("br"),a("span",{staticClass:"line-number"},[s._v("19")]),a("br"),a("span",{staticClass:"line-number"},[s._v("20")]),a("br"),a("span",{staticClass:"line-number"},[s._v("21")]),a("br")])]),a("p",[s._v("通常情况下,对于路由的定义,不设置 "),a("code",[s._v("name")]),s._v(" 属性,推荐仅对于使用频率较高的功能模块设置,例如登录、首页等最经常被使用的模块,另外就是业务中也经常会被多个场景中使用的情况")]),s._v(" "),a("h3",{attrs:{id:"异步加载页面-组件"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#异步加载页面-组件","aria-hidden":"true"}},[s._v("#")]),s._v(" 异步加载页面/组件")]),s._v(" "),a("p",[s._v("对于路由的定义推荐使用以下模式")]),s._v(" "),a("div",{staticClass:"language-js line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-js"}},[a("code",[a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("[")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("{")]),s._v("\n path"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'/aaa/bbb'")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(",")]),s._v("\n "),a("span",{pre:!0,attrs:{class:"token function-variable function"}},[s._v("component")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(":")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(")")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[s._v("=>")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[s._v("import")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'@/views/abc'")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v(")")]),s._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("}")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[s._v("]")]),s._v("\n")])]),s._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[s._v("1")]),a("br"),a("span",{staticClass:"line-number"},[s._v("2")]),a("br"),a("span",{staticClass:"line-number"},[s._v("3")]),a("br"),a("span",{staticClass:"line-number"},[s._v("4")]),a("br")])])])},[],!1,null,null,null);t.default=e.exports}}]);