Skip to content

Commit

Permalink
fix(form): 对齐属性
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczj committed Sep 6, 2018
1 parent 15ca3a1 commit e632bfa
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
7 changes: 6 additions & 1 deletion @types/form.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { MouseEvent, ComponentClass } from 'react'
import { BaseEvent } from '@tarojs/components/types/common'

declare type FormFunction = (event: BaseEvent) => void
export interface AtFormProps {
style?: string | object
style?: string | object,
reportSubmit?: boolean,
onSubmit?: FormFunction,
onReset?: FormFunction
}

declare const AtForm: ComponentClass<AtFormProps>
Expand Down
41 changes: 36 additions & 5 deletions src/components/form/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,55 @@
import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'
import { Form } from '@tarojs/components'
import PropTypes from 'prop-types'

import AtComponent from '../../common/component'
import './index.scss'

class AtForm extends AtComponent {
onSubmit () {
this.props.onSubmit(...arguments)
}

reportSubmit () {
this.props.reportSubmit(...arguments)
}

onReset () {
this.props.onReset(...arguments)
}

render () {
return <View className='at-form' style={this.props.style}>
const { style, reportSubmit } = this.props

return <Form
className='at-form'
style={style}
onSubmit={this.onSubmit.bind(this)}
reportSubmit={reportSubmit}
onReset={this.onReset.bind(this)}
>
{this.props.children}
</View>
</Form>
}
}

const defaultFunc = () => {}

AtForm.defaultProps = {
style: ''
style: '',
reportSubmit: false,
onSubmit: defaultFunc,
onReset: defaultFunc
}

AtForm.propTypes = {
style: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string
])
]),
reportSubmit: PropTypes.bool,
onSubmit: PropTypes.func,
onReset: PropTypes.func
}

export default AtForm

0 comments on commit e632bfa

Please sign in to comment.