You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.7 KiB
72 lines
1.7 KiB
import baseComponent from '../helpers/baseComponent'
|
|
import classNames from '../helpers/classNames'
|
|
|
|
baseComponent({
|
|
relations: {
|
|
'../tabbar/index': {
|
|
type: 'parent',
|
|
},
|
|
},
|
|
properties: {
|
|
prefixCls: {
|
|
type: String,
|
|
value: 'wux-tabbar-item',
|
|
},
|
|
key: {
|
|
type: String,
|
|
value: '',
|
|
},
|
|
title: {
|
|
type: String,
|
|
value: '',
|
|
},
|
|
disabled: {
|
|
type: Boolean,
|
|
value: false,
|
|
},
|
|
},
|
|
data: {
|
|
width: '100%',
|
|
current: false,
|
|
index: '0',
|
|
},
|
|
computed: {
|
|
classes: ['prefixCls, theme, current, disabled', function(prefixCls, theme, current, disabled) {
|
|
const wrap = classNames(prefixCls, {
|
|
[`${prefixCls}--${theme}`]: theme,
|
|
[`${prefixCls}--current`]: current,
|
|
[`${prefixCls}--disabled`]: disabled,
|
|
})
|
|
const icon = `${prefixCls}__icon`
|
|
const title = `${prefixCls}__title`
|
|
|
|
return {
|
|
wrap,
|
|
icon,
|
|
title,
|
|
}
|
|
}],
|
|
},
|
|
methods: {
|
|
changeCurrent(current, index, theme, length) {
|
|
const width = 100 / length + '%'
|
|
|
|
this.setData({
|
|
width,
|
|
current,
|
|
theme,
|
|
index,
|
|
})
|
|
},
|
|
onTap() {
|
|
const { index, disabled } = this.data
|
|
const parent = this.getRelationNodes('../tabbar/index')[0]
|
|
|
|
if (disabled || !parent) return
|
|
|
|
this.triggerEvent('click', { index })
|
|
|
|
parent.setActiveKey(index)
|
|
},
|
|
},
|
|
})
|
|
|