-
Notifications
You must be signed in to change notification settings - Fork 4.9k
onClick方法被频繁调用,不停给服务器发请求 #2738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
欢迎提交 Issue~ 如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏 如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。 Good luck and happy coding~ |
是你调用的方式错了,onClick={ this.onPoor() }, 这样是不管点击不点击,onPoor都是会被调用的,因为你加了(),所以在渲染的时候,就会执行。onClick={() => this.onPoor() },这样试试吧 |
react文档也建议好好看下, 不要在触发事件上写可直接执行的方法 |
Hello~ 您的问题楼上已经有了确切的回答,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。 如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。 Good luck and happy coding~ |
|
这样写 |
|
Uh oh!
There was an error while loading. Please reload this page.
问题描述
[问题描述:站在其它人的角度尽可能清晰地、简洁地把问题描述清楚]
按钮点击事件在view渲染时onClick方法被频繁调用,不停给服务器发请求,停止运行在浏览器还是不停发送请求
复现步骤
[复现问题的步骤]
import Taro, {Component} from '@tarojs/taro'

import {View} from '@tarojs/components'
import isEmpty from 'lodash/isEmpty'
import './index.scss'
import {AtButton, AtIcon, AtList} from "taro-ui";
import {connect} from "@tarojs/redux";
@connect(({door, loading}) => ({
...door,
openDoor: loading.effects["door/openDoor"],
}))
export default class Door extends Component {
constructor (props) {
super(props)
console.log(props)
}
``

期望行为
期望点击按钮再触发点击事件,而不是打开页面直接触发
报错信息
[这里请贴上你的完整报错截图或文字]
系统信息
� Taro v1.2.22
Taro CLI 1.2.22 environment info:
System:
OS: Windows 7
Binaries:
Node: 10.15.3 - C:\Program Files\nodejs\node.EXE
Yarn: 1.15.2 - C:\Users\lenovo\AppData\Roaming\npm\yarn.CMD
npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
npm run dev:h5
补充信息
出现这个问题的原因可能在点击事件这里,但是无论我在哪里调用这个方法都会出现频繁请求
我把调用的方法放在onPullDownRefresh也会频繁请求
已经排除了js和路由的问题,也不是后端的问题
The text was updated successfully, but these errors were encountered: