From af0158d828f810f31985d915d8d1a7bcdf723b89 Mon Sep 17 00:00:00 2001 From: cos2004 Date: Thu, 19 Jul 2018 22:24:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(base):=20=E6=8C=89=E9=92=AE=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/button/index.js | 11 ++++++++--- src/components/icon/index.js | 4 ++-- src/pages/view/button/index.js | 10 +++++----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/components/button/index.js b/src/components/button/index.js index 45c1faa28..92c028d4f 100644 --- a/src/components/button/index.js +++ b/src/components/button/index.js @@ -1,5 +1,6 @@ import Taro from "@tarojs/taro" import { View } from "@tarojs/components" +import { AtIcon } from "../icon/index" import './index.scss' @@ -24,8 +25,8 @@ export default class AtButton extends Taro.Component { } onClick(e) { - if (!this.props.disabled) { - this.props.onClick && this.props.onClick(e) + if (!this.props.disabled && this.props.onClick) { + this.props.onClick(e) } } @@ -43,12 +44,16 @@ export default class AtButton extends Taro.Component { let disabledClass = disabled? 'at-button--disabled': '' let typeClass = TYPE_CLASS[type]? `at-button--${type}`: '' let activeClass = active? 'at-button--active': '' + // let loadingClass = loading? 'at-button--loading': '' + // let iconClass = loading? 'at-button--icon': '' rootClassName.push(`at-button--${sizeClass}`, disabledClass, typeClass, activeClass) rootClassName = rootClassName.filter(str => str != '') - // console.log(this.props, this.state) + console.log('loading====', loading) return ( + {loading && } + {icon && } {this.props.children} ) diff --git a/src/components/icon/index.js b/src/components/icon/index.js index e10caaca5..b6c8f7637 100644 --- a/src/components/icon/index.js +++ b/src/components/icon/index.js @@ -9,7 +9,7 @@ export default class AtIcon extends Taro.Component { } render() { - let { value, size = 24, color = '#000'} = this.props + let { value = '', size = 24, color = '#000'} = this.props const rootStyle = { // width: `${+size}px`, @@ -19,7 +19,7 @@ export default class AtIcon extends Taro.Component { } let rootClassName = ['at-icon', `at-icon-${value}`] - + console.log('value====',value) return ( ) diff --git a/src/pages/view/button/index.js b/src/pages/view/button/index.js index 6c342b8c5..e0116b74b 100644 --- a/src/pages/view/button/index.js +++ b/src/pages/view/button/index.js @@ -13,10 +13,7 @@ export default class ButtonPage extends Taro.Component { constructor() { super(...arguments) this.state = { - // icons: [ - // 'arrow-left', - // 'arrow-down-left', - // ] + } } @@ -32,7 +29,10 @@ export default class ButtonPage extends Taro.Component { 页面主操作 - 带icon + 带loading + + + 带icon 点击态