diff --git a/src/components/button/index.js b/src/components/button/index.js index 0e20bf0ae..45c1faa28 100644 --- a/src/components/button/index.js +++ b/src/components/button/index.js @@ -11,6 +11,7 @@ const SIZE_CLASS = { const TYPE_CLASS = { primary: 'primary', + secondary: 'secondary', } @@ -22,15 +23,18 @@ export default class AtButton extends Taro.Component { } } - onClick() { - console.log('ddasddas') + onClick(e) { + if (!this.props.disabled) { + this.props.onClick && this.props.onClick(e) + } } render(){ let { size = 'normal', - type = 'primary', + type = '', icon = '', + active = false, loading = false, disabled = false, } = this.props @@ -38,13 +42,14 @@ export default class AtButton extends Taro.Component { let sizeClass = SIZE_CLASS[size] || '' let disabledClass = disabled? 'at-button--disabled': '' let typeClass = TYPE_CLASS[type]? `at-button--${type}`: '' + let activeClass = active? 'at-button--active': '' - rootClassName.push(`at-button--${sizeClass}`, disabledClass, typeClass) + rootClassName.push(`at-button--${sizeClass}`, disabledClass, typeClass, activeClass) rootClassName = rootClassName.filter(str => str != '') -console.log(this.props, this.state) + // console.log(this.props, this.state) return ( - - 测试按钮 + + {this.props.children} ) } diff --git a/src/components/button/index.scss b/src/components/button/index.scss index c0c2615d0..ebf16b270 100644 --- a/src/components/button/index.scss +++ b/src/components/button/index.scss @@ -8,20 +8,24 @@ font-size: 32px; margin: 0 auto; - border: 2px solid #6190E8; + border: 2px solid #ccc; background-color: #fff; - color: #6190E8; + color: #333; box-sizing: border-box; &--active { - opacity: .8; + opacity: .6; } &--disabled { - opacity: .5; + opacity: .3; } &--primary { background-color: rgba(92, 137, 228, 1); color: #fff; - border: none; - + border: 2px solid rgba(92, 137, 228, 1); + } + &--secondary { + background-color: #fff; + color: rgba(92, 137, 228, 1); + border: 2px solid rgba(92, 137, 228, 1); } } \ No newline at end of file diff --git a/src/pages/index/index.js b/src/pages/index/index.js index f7ec791fc..f49023181 100644 --- a/src/pages/index/index.js +++ b/src/pages/index/index.js @@ -195,7 +195,10 @@ export default class Index extends Taro.Component { return ( {child.name.split('-').join('')} {child.title} diff --git a/src/pages/view/button/index.js b/src/pages/view/button/index.js index 8918cf828..6c342b8c5 100644 --- a/src/pages/view/button/index.js +++ b/src/pages/view/button/index.js @@ -20,24 +20,52 @@ export default class ButtonPage extends Taro.Component { } } + onButtonClick() { + alert('点击了!') + } + render() { // let {icons} = this.state return ( - 测试按钮 + 页面主操作 + + + 带icon + + + 点击态 + + + 不可操作 + + + + 页面次操作 + + + 带icon + + + 点击态 + + + 不可操作 + + - 测试按钮 + 页面次要操作 - 测试按钮 + 带icon - 测试按钮 + 点击态 - 测试按钮 + 不可操作 )