diff --git a/src/components/tabs-pane/index.js b/src/components/tabs-pane/index.js
new file mode 100644
index 000000000..e7b0619e6
--- /dev/null
+++ b/src/components/tabs-pane/index.js
@@ -0,0 +1,22 @@
+import Taro from '@tarojs/taro'
+import { View } from '@tarojs/components'
+import './index.scss'
+
+/**
+ * @author:chenzeji
+ * @description tabs 标签页
+ * @prop current {Number} 当前选中的tab index值,从0计数,default:0
+ * @prop color {String} 选中标签的颜色
+ * @prop scroll {Boolean} 是否横向滚动,default:false
+ * @prop tabList {Array} tab 列表 eg: [{ title: '标签页1' }, { title: '标签页2' }]
+ * @prop onClick {Function} 点击时触发事件,回调参数 {value: 1}
+ */
+class AtTabsPane extends Taro.Component {
+ render () {
+ return
+ {this.props.children}
+
+ }
+}
+
+export default AtTabsPane
diff --git a/src/components/tabs-pane/index.scss b/src/components/tabs-pane/index.scss
new file mode 100644
index 000000000..71ab2a690
--- /dev/null
+++ b/src/components/tabs-pane/index.scss
@@ -0,0 +1,6 @@
+.tabs-pane {
+ display: inline-block;
+ width: 100%;
+ white-space: initial;
+ vertical-align: top;
+}
diff --git a/src/components/tabs/index.js b/src/components/tabs/index.js
index d5b13d9f3..903b80cef 100644
--- a/src/components/tabs/index.js
+++ b/src/components/tabs/index.js
@@ -19,17 +19,23 @@ class AtTabs extends Taro.Component {
render () {
const { tabList, scroll, current, color } = this.props
- const rootCls = ['at-tabs']
+ const headerCls = ['at-tabs__header']
const style = `color: ${color};border-bottom: 1px solid ${color};`
if (scroll) {
- rootCls.push('at-tabs--scroll')
+ headerCls.push('at-tabs__header--scroll')
}
- return
- {
- tabList.map((item, i) =>
- {item.title}
- )
- }
+ const animationStyle = `transform: translate3d(-${current * 100}%, 0px, 0px);`
+ return
+
+ {
+ tabList.map((item, i) =>
+ {item.title}
+ )
+ }
+
+
+ {this.props.children}
+
}
}
diff --git a/src/components/tabs/index.scss b/src/components/tabs/index.scss
index ae8a31056..ebbbeef5c 100644
--- a/src/components/tabs/index.scss
+++ b/src/components/tabs/index.scss
@@ -2,13 +2,6 @@
@import '../../style/theme/default.scss';
.at-tabs {
- background-color: $color-bg;
- display: flex;
- text-align: center;
- width: 100%;
- box-sizing: border-box;
- white-space: nowrap;
-
&__item {
flex: 1;
font-size: 30px;
@@ -16,12 +9,28 @@
color: $color-text-base;
}
- &--scroll {
- overflow-x: auto;
+ &__header {
+ background-color: $color-bg;
+ display: flex;
+ text-align: center;
+ width: 100%;
+ box-sizing: border-box;
white-space: nowrap;
- .at-tabs__item {
- display: inline-block;
+ &--scroll {
+ overflow-x: auto;
+ white-space: nowrap;
+
+ .at-tabs__item {
+ display: inline-block;
+ }
}
}
+
+ &__body {
+ display: block;
+ font-size: 0;
+ white-space: nowrap;
+ transition: all 0.3s;
+ }
}
diff --git a/src/pages/navigation/tabs/index.js b/src/pages/navigation/tabs/index.js
index 215d6173c..992e68405 100644
--- a/src/pages/navigation/tabs/index.js
+++ b/src/pages/navigation/tabs/index.js
@@ -2,6 +2,7 @@
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
import AtTabs from '../../../components/tabs/index'
+import AtTabsPane from '../../../components/tabs-pane/index'
import DocsHeader from '../../components/doc-header'
import './index.scss'
@@ -43,20 +44,16 @@ export default class Index extends Taro.Component {
基础用法
-
- {
- current1 === 0
- ? 标签页一的内容
- : null
- }
- {
- current1 === 1
- ? 标签页二的内容
- : null
- }
+
+
+ 标签页一的内容
+
+
+ 标签页二的内容
+
+
-
{/* 滚动 */}
滚动