ソースを参照

docs: 文档和示例代码优化

zhaihaoyi 6 年 前
コミット
672321a9f1

+ 4 - 6
docs/guide.md

@@ -99,7 +99,7 @@ export default new Router({
         title: '页面', // 页签标题
         icon: 'icon-user', // 页签图标,可选
         tips: '这是一个页面', // 页签提示,可选,如未设置则跟title一致
-        aliveKey: 'fullPath', // 路由打开页签规则,可选
+        aliveId: 'fullPath', // 路由打开页签规则,可选
       }
     }, {
       path: '/404',
@@ -553,18 +553,16 @@ export default {
 
 **示例:**
 
-``` javascript {3,17,23,25,30}
+``` javascript {3,15,21,23,28}
 export default {
   // 页面离开前确认
   beforePageLeave (resolve, reject, tab, type) {
     // 离开类型
-    const types = {
+    const action = {
       close: '关闭',
       refresh: '刷新',
       replace: '替换'
-    }
-
-    const action = types[type]
+    }[type]
 
     const msg = `您确认要${action}页签“${tab.title}”吗?`
 

+ 6 - 3
src/components/layout/LanguageCustom.vue → src/components/layout/LangCustom.vue

@@ -1,15 +1,15 @@
 <template>
   <main class="app-main">
-    <router-tab :i18n="lang"/>
+    <router-tab :i18n="customLanguage"/>
   </main>
 </template>
 
 <script>
 export default {
-  name: 'LanguageCustom',
+  name: 'LangCustom',
   data () {
     return {
-      lang: {
+      customLanguage: {
         tab: {
           untitled: 'Untitled Page'
         },
@@ -20,6 +20,9 @@ export default {
           closeLefts: 'Close to the Left',
           closeRights: 'Close to the Right',
           closeOthers: 'Close Others'
+        },
+        msg: {
+          keepOneTab: 'Keep at least 1 tab'
         }
       }
     }

+ 0 - 0
src/components/layout/Language.vue → src/components/layout/LangEn.vue


+ 2 - 2
src/router.js

@@ -69,12 +69,12 @@ export default new Router({
     children: pageRoutes
   }, {
     path: '/lang-en/',
-    component: importLayout('Language'),
+    component: importLayout('LangEn'),
     redirect: '/lang-en/page/1',
     children: pageRoutes
   }, {
     path: '/lang-custom/',
-    component: importLayout('LanguageCustom'),
+    component: importLayout('LangCustom'),
     redirect: '/lang-custom/page/1',
     children: pageRoutes
   }, {

+ 2 - 4
src/views/PageLeave.vue

@@ -38,13 +38,11 @@ export default {
   // 页面离开前确认
   beforePageLeave (resolve, reject, tab, type) {
     // 离开类型
-    const types = {
+    const action = {
       close: '关闭',
       refresh: '刷新',
       replace: '替换'
-    }
-
-    const action = types[type]
+    }[type]
 
     const msg = `您确认要${action}页签“${tab.title}”吗?`