Skip to content

Commit

Permalink
fix(#1270) : 解决 AtButton formType='submit' 微信小程序下不能触发事件 #1270 (#1533)
Browse files Browse the repository at this point in the history
  • Loading branch information
dengxiang committed Sep 30, 2022
1 parent 35d8427 commit 829595e
Showing 1 changed file with 2 additions and 33 deletions.
35 changes: 2 additions & 33 deletions packages/taro-ui/src/components/button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames'
import PropTypes, { InferProps } from 'prop-types'
import React from 'react'
import { Button, Form, View } from '@tarojs/components'
import { Button, View } from '@tarojs/components'
import { ButtonProps } from '@tarojs/components/types/Button'
import { BaseEventOrig, CommonEvent } from '@tarojs/components/types/common'
import Taro from '@tarojs/taro'
Expand Down Expand Up @@ -62,30 +62,6 @@ export default class AtButton extends React.Component<
this.props.onOpenSetting && this.props.onOpenSetting(event)
}

private onSumit(event: CommonEvent): void {
if (this.state.isWEAPP || this.state.isWEB) {
// TODO: 3.0 this.$scope
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
this.$scope.triggerEvent('submit', event.detail, {
bubbles: true,
composed: true
})
}
}

private onReset(event: CommonEvent): void {
if (this.state.isWEAPP || this.state.isWEB) {
// TODO: 3.0 this.$scope
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
this.$scope.triggerEvent('reset', event.detail, {
bubbles: true,
composed: true
})
}
}

public render(): JSX.Element {
const {
size = 'normal',
Expand Down Expand Up @@ -162,14 +138,7 @@ export default class AtButton extends React.Component<
onClick={this.onClick.bind(this)}
>
{isWEB && !disabled && webButton}
{isWEAPP && !disabled && (
<Form
onSubmit={this.onSumit.bind(this)}
onReset={this.onReset.bind(this)}
>
{button}
</Form>
)}
{isWEAPP && !disabled && button}
{isALIPAY && !disabled && button}
{loadingComponent}
<View className='at-button__text'>{this.props.children}</View>
Expand Down

0 comments on commit 829595e

Please sign in to comment.