From d2291f37104f0ad8ce9bef3ccffac668342d096d Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Sun, 26 Jul 2020 15:29:52 +0800 Subject: [PATCH] feat: migrate Tab component --- breaking-changes.md | 3 +- components.js | 3 ++ src/tab/README.md | 18 +++++----- src/tab/README.zh-CN.md | 20 +++++------ src/tab/demo/index.vue | 4 +-- src/tab/index.js | 6 ++-- src/tabs/Content.js | 17 +++++---- src/tabs/Title.js | 3 +- src/tabs/index.js | 79 +++++++++++++++++++++-------------------- vant.config.js | 32 ++++++++--------- 10 files changed, 97 insertions(+), 88 deletions(-) diff --git a/breaking-changes.md b/breaking-changes.md index e55b7c0d5..a5d59d872 100644 --- a/breaking-changes.md +++ b/breaking-changes.md @@ -4,8 +4,9 @@ 以下改动是为了适配 Vue 3 的 v-model API 用法变更: -- Circle: `v-model` 重命名为 `v-model:currentRate` +- Tabs: `v-model` 重命名为 `v-model:active` - Popup: `v-model` 重命名为 `v-model:show` +- Circle: `v-model` 重命名为 `v-model:currentRate` - ShareSheet: `v-model` 重命名为 `v-model:show` - ActionSheet: `v-model` 重命名为 `v-model:show` - List: `v-model` 重命名为 `v-model:loading`,`error.sync` 重命名为 `v-model:error` diff --git a/components.js b/components.js index 87557aa4c..5a02e8202 100644 --- a/components.js +++ b/components.js @@ -40,4 +40,7 @@ module.exports = [ 'tabbar', 'tabbar-item', 'list', + 'tab', + 'tabs', + 'sticky', ]; diff --git a/src/tab/README.md b/src/tab/README.md index 714912b34..6d6f2e65e 100644 --- a/src/tab/README.md +++ b/src/tab/README.md @@ -14,10 +14,10 @@ Vue.use(Tabs); ### Basic Usage -The first tab is actived by default, you can set `v-model` to active specified tab. +The first tab is actived by default, you can set `v-model:active` to active specified tab. ```html - + content of tab {{ index }} @@ -37,7 +37,7 @@ export default { ### Match By Name ```html - + content of tab 1 content of tab 2 content of tab 3 @@ -129,7 +129,7 @@ export default { In sticky mode, the tab will be fixed to top when scroll to top. ```html - + content {{ index }} @@ -141,7 +141,7 @@ In sticky mode, the tab will be fixed to top when scroll to top. Use title slot to custom tab title. ```html - + content {{ index }} @@ -154,7 +154,7 @@ Use title slot to custom tab title. Use `animated` props to change tabs with animation. ```html - + content {{ index }} @@ -166,7 +166,7 @@ Use `animated` props to change tabs with animation. In swipeable mode, you can switch tabs with swipe gestrue in the content. ```html - + content {{ index }} @@ -178,7 +178,7 @@ In swipeable mode, you can switch tabs with swipe gestrue in the content. In scrollspy mode, the list of content will be tiled. ```html - + content {{ index }} @@ -219,7 +219,7 @@ export default { | Attribute | Description | Type | Default | | --- | --- | --- | --- | -| v-model | Index of active tab | _number \| string_ | `0` | +| v-model:active | Index of active tab | _number \| string_ | `0` | | type | Can be set to `line` `card` | _string_ | `line` | | color | Tab color | _string_ | `#ee0a24` | | background | Background color | _string_ | `white` | diff --git a/src/tab/README.zh-CN.md b/src/tab/README.zh-CN.md index a2ba20c5b..ead80003c 100644 --- a/src/tab/README.zh-CN.md +++ b/src/tab/README.zh-CN.md @@ -14,10 +14,10 @@ Vue.use(Tabs); ### 基础用法 -通过 `v-model` 绑定当前激活标签对应的索引值,默认情况下启用第一个标签。 +通过 `v-model:active` 绑定当前激活标签对应的索引值,默认情况下启用第一个标签。 ```html - + 内容 1 内容 2 内容 3 @@ -37,10 +37,10 @@ export default { ### 通过名称匹配 -在标签指定 `name` 属性的情况下,`v-model` 的值为当前标签的 `name`(此时无法通过索引值来匹配标签)。 +在标签指定 `name` 属性的情况下,`v-model:active` 的值为当前标签的 `name`(此时无法通过索引值来匹配标签)。 ```html - + 内容 1 内容 2 内容 3 @@ -133,7 +133,7 @@ export default { 通过 `sticky` 属性可以开启粘性布局,粘性布局下,标签页滚动到顶部时会自动吸顶。 ```html - + 内容 {{ index }} @@ -145,7 +145,7 @@ export default { 通过 `title` 插槽可以自定义标签内容。 ```html - + 内容 {{ index }} @@ -158,7 +158,7 @@ export default { 通过 `animated` 属性可以开启切换标签内容时的转场动画。 ```html - + 内容 {{ index }} @@ -170,7 +170,7 @@ export default { 通过 `swipeable` 属性可以开启滑动切换标签页。 ```html - + 内容 {{ index }} @@ -182,7 +182,7 @@ export default { 通过 `scrollspy` 属性可以开启滚动导航模式,该模式下,内容将会平铺展示。 ```html - + 内容 {{ index }} @@ -226,7 +226,7 @@ export default { | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| v-model | 绑定当前选中标签的标识符 | _number \| string_ | `0` | +| v-model:active | 绑定当前选中标签的标识符 | _number \| string_ | `0` | | type | 样式风格类型,可选值为`card` | _string_ | `line` | | color | 标签主题色 | _string_ | `#ee0a24` | | background | 标签栏背景色 | _string_ | `white` | diff --git a/src/tab/demo/index.vue b/src/tab/demo/index.vue index 9d24cac71..4a1bf2451 100644 --- a/src/tab/demo/index.vue +++ b/src/tab/demo/index.vue @@ -1,7 +1,7 @@