This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
yoshop-wechat/components/btn/index.js

61 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2020-04-25 22:59:04 +08:00
'use strict';
var nativeButtonBehavior = require('./native-button-behaviors');
Component({
externalClasses: ['custom-class', 'theme-class'],
behaviors: [nativeButtonBehavior],
relations: {
'../btn-group/index': {
type: 'parent',
linked: function linked() {
this.setData({ inGroup: true });
},
unlinked: function unlinked() {
this.setData({ inGroup: false });
}
}
},
properties: {
type: {
type: String,
value: ''
},
size: {
type: String,
value: ''
},
plain: {
type: Boolean,
value: false
},
disabled: {
type: Boolean,
value: false
},
loading: {
type: Boolean,
value: false
}
},
data: {
inGroup: false,
isLast: false
},
methods: {
handleTap: function handleTap() {
if (this.data.disabled) {
this.triggerEvent('disabledclick');
return;
}
this.triggerEvent('btnclick');
},
switchLastButtonStatus: function switchLastButtonStatus() {
var isLast = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
this.setData({ isLast: isLast });
}
}
});