diff --git a/docs/examples-docs/tab.md b/docs/examples-docs/tab.md index a6f3f2735..60d94bd4f 100644 --- a/docs/examples-docs/tab.md +++ b/docs/examples-docs/tab.md @@ -2,25 +2,90 @@ ### 基础用法 +:::demo 基础用法 ```html - 内容一 - 内容二 - 内容三 - 内容四 - 内容五 + 内容一 + 内容二 + 内容三 + 内容四 + 内容五 ``` -### 自定义样式用法 - + +::: +### 禁用用法 +:::demo 禁用用法 ```html - - 内容一 - 内容二 - 内容三 - 内容四 - 内容五 + + 内容一 + 内容二 + 内容三 + 内容四 + 内容五 + + +``` +::: + +### card样式用法 +:::demo card样式用法 +```html + + 内容一 + 内容二 + 内容三 + 内容四 + 内容五 + +``` +::: + + +### 自定义样式用法 +:::demo 自定义样式用法 +```html + + 内容一 + 内容二 + 内容三 + 内容四 + 内容五 ``` - +::: ### zan-tabs API -| 参数 | 说明 | 类型 | 默认值 | 必须 | +| 参数 | 说明 | 类型 | 默认值 | 可选 | |-----------|-----------|-----------|-------------|-------------| -| active-key | 激活的badge的索引 | string | '0'但必须子badge里的mark是有0位索引 | | +| classtype | 两种UI | string | line | card | +| active | 默认激活的tab | string || number | 0 | | +| classname | tabs自定义classname | string | '' | | -### z-badge API +### zan-tab API | 参数 | 说明 | 类型 | 默认值 | 必须 | |-----------|-----------|-----------|-------------|-------------| -| mark | badge的唯一key值 | string | '' | required | -| title | badge的文案标题 | string | '' | required | -| info | 当前badge的提示消息数量 | string | '' | | -| url | 跳转链接 | string | 全连接直接跳转或者hash | | +| title | tab的标题 | string | '' | required | +| paneclass | 底部内容区的classname | string | '' | | +| disable | 是否禁用这个tab | Boolean | false | | + diff --git a/packages/tab/src/tab.vue b/packages/tab/src/tab.vue index ed9dd328b..196173c29 100644 --- a/packages/tab/src/tab.vue +++ b/packages/tab/src/tab.vue @@ -8,30 +8,26 @@ export default { name: 'zan-tab', props: { - // 对应 Tabs 组件的 activeKey - tabKey: { - type: [Number, String], - required: true - }, // 选项卡头显示文字 title: { type: String, required: true }, - tabPaneClassName: { + paneclass: { type: String - } + }, + disable: Boolean }, computed: { classNames() { return [ - {'is-select': this.tabKey == this.$parent.switchActiveTabKey}, - this.tabPaneClassName + {'is-select': this.$parent.tabs.indexOf(this) == this.$parent.switchActiveTabKey }, + this.paneclass ]; } }, created () { - this.$parent.tabCreate(this.tabKey, this.title); + this.$parent.tabs.push(this); } }; diff --git a/packages/tab/src/tabs.vue b/packages/tab/src/tabs.vue index ac87fe140..bd79fb80b 100644 --- a/packages/tab/src/tabs.vue +++ b/packages/tab/src/tabs.vue @@ -3,11 +3,11 @@
{{ tab.title }}
@@ -21,41 +21,36 @@ name: 'zan-tabs', props: { // 外部传入的激活的tab标签 - activeTabKey: { + active: { type: [Number, String], default: 0 }, // 是默认的line还是card - classType: { + classtype: { type: String, default: 'line' }, // nav的wrap的样式 - tabsClassName: { + classname: { type: String, default: '' - }, - // 每个nav里tab的样式 - tabClassName: { - type: String } }, data() { return { tabs: [], isReady: false, - switchActiveTabKey: this.activeTabKey + switchActiveTabKey: this.active }; }, computed: { classNames () { - return [ `zan-tabs-${this.classType}`, this.tabsClassName ] + return [ `zan-tabs-${this.classtype}`, this.classname ] }, navBarStyle () { if(!this.isReady) return; let tabKey = this.switchActiveTabKey; - let selectors = `.J-tab-key[data-key="${tabKey}"]`; - let elem = this.$el.querySelector(selectors) || {}; + let elem = this.$refs.tabkey[tabKey]; let w = `${elem.offsetWidth || 0}px`; let x = `${elem.offsetLeft || 0}px`; return { @@ -65,14 +60,12 @@ } }, methods: { - tabCreate (tabKey, title) { - this.tabs.push({ - tabKey: tabKey, - title: title - }); - }, - handleTabClick(tabKey) { - this.switchActiveTabKey = tabKey; + handleTabClick(index, el) { + if(el.disable) { + el.$emit('ondisable'); + return + } + this.switchActiveTabKey = index; } }, mounted () { diff --git a/src/index.js b/src/index.js index 4503f31bd..71103a6fb 100644 --- a/src/index.js +++ b/src/index.js @@ -23,6 +23,7 @@ import Search from '../packages/search/index.js'; import Step from '../packages/step/index.js'; import Tabs from '../packages/tabs/index.js'; import Tab from '../packages/tab/index.js'; +import Lazyload from '../packages/lazyload/index.js'; import ImagePreview from '../packages/image-preview/index.js'; import Col from '../packages/col/index.js'; import Row from '../packages/row/index.js'; @@ -92,6 +93,7 @@ module.exports = { Step, Tabs, Tab, + Lazyload, ImagePreview, Col, Row,