[improvement] Tab: support custom-class (#612)

This commit is contained in:
neverland 2018-09-20 16:45:58 +08:00 committed by GitHub
parent 6dceff823e
commit 634fb744a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 6 deletions

View File

@ -31,16 +31,19 @@ create({
} }
} }
}, },
data: { data: {
pickerValue: [0, 0, 0], pickerValue: [0, 0, 0],
columns: [] columns: []
}, },
computed: { computed: {
displayColumns() { displayColumns() {
const { columns = [], columnsNum } = this.data; const { columns = [], columnsNum } = this.data;
return columns.slice(0, +columnsNum); return columns.slice(0, +columnsNum);
} }
}, },
methods: { methods: {
onCancel() { onCancel() {
this.triggerEvent('cancel', { this.triggerEvent('cancel', {

View File

@ -5,6 +5,7 @@ create({
'price-class', 'price-class',
'button-class' 'button-class'
], ],
props: { props: {
tip: [String, Boolean], tip: [String, Boolean],
type: Number, type: Number,
@ -22,21 +23,22 @@ create({
value: 'danger' value: 'danger'
} }
}, },
options: {
multipleSlots: true
},
computed: { computed: {
hasPrice() { hasPrice() {
return typeof this.data.price === 'number'; return typeof this.data.price === 'number';
}, },
priceStr() { priceStr() {
return (this.data.price / 100).toFixed(2); return (this.data.price / 100).toFixed(2);
}, },
tipStr() { tipStr() {
const { tip } = this.data; const { tip } = this.data;
return typeof tip === 'string' ? tip : ''; return typeof tip === 'string' ? tip : '';
} }
}, },
methods: { methods: {
onSubmit(event) { onSubmit(event) {
this.$emit('submit', event.detail); this.$emit('submit', event.detail);

View File

@ -144,10 +144,16 @@ Page({
| bind:change | 当前激活的标签改变时触发 | index标签索引title标题 | | bind:change | 当前激活的标签改变时触发 | index标签索引title标题 |
| bind:disabled | 点击被禁用的标签时触发 | index标签索引title标题 | | bind:disabled | 点击被禁用的标签时触发 | index标签索引title标题 |
### 外部样式类
| 类名 | 说明 |
|-----------|-----------|
| custom-class | 根节点样式类 |
### 更新日志 ### 更新日志
| 版本 | 类型 | 内容 | | 版本 | 类型 | 内容 |
|-----------|-----------|-----------| |-----------|-----------|-----------|
| 0.3.0 | feature | 新增组件 | | 0.3.0 | feature | 新增组件 |
| 0.3.2 | bugfix | 修复部分情况下代码报错的问题 | | 0.3.2 | bugfix | 修复部分情况下代码报错的问题 |
| 0.3.2 | bugfix | 修复 color 属性会改变未激活标签的颜色的问题 | | 0.3.2 | bugfix | 修复 color 属性会改变未激活标签的颜色的问题 |

View File

@ -1,6 +1,6 @@
<view <view
wx:if="{{ inited }}" wx:if="{{ inited }}"
class="van-tab__pane" class="custom-class van-tab__pane"
style="{{ active ? '' : 'display: none' }}" style="{{ active ? '' : 'display: none' }}"
> >
<slot /> <slot />

View File

@ -1,4 +1,4 @@
<view class="van-tabs van-tabs--{{ type }}"> <view class="custom-class van-tabs van-tabs--{{ type }}">
<view class="van-tabs__wrap {{ scrollable ? 'van-tabs__wrap--scrollable' : '' }} {{ type === 'line' && border ? 'van-hairline--top-bottom' : '' }}"> <view class="van-tabs__wrap {{ scrollable ? 'van-tabs__wrap--scrollable' : '' }} {{ type === 'line' && border ? 'van-hairline--top-bottom' : '' }}">
<scroll-view <scroll-view
scroll-x="{{ scrollable }}" scroll-x="{{ scrollable }}"