We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
替换图片,用$on监听上传图片完成,$emit在图片上传完成以后触发。
$on
$emit
结果第一次点击,上传一次;第二次点击,上传两次;第三次点击,上传三次。
然而$emit实际只触发了一次,只是$on被触发了多次。
怀疑是发布订阅的池子里,因为每一次点击图片,$emit就push进去一个uploadSuccess,但是后续触发了$on以后,并没有把池子里的uploadSuccess删掉,所以之后会触发与点击次数同等多的$on
push
uploadSuccess
在每次$on前,先$off,清除uploadSuccess,再重新添加$on
$off
The text was updated successfully, but these errors were encountered:
No branches or pull requests
场景
替换图片,用
$on
监听上传图片完成,$emit
在图片上传完成以后触发。结果
结果第一次点击,上传一次;第二次点击,上传两次;第三次点击,上传三次。
然而
$emit
实际只触发了一次,只是$on
被触发了多次。怀疑原因
怀疑是发布订阅的池子里,因为每一次点击图片,
$emit
就push
进去一个uploadSuccess
,但是后续触发了$on
以后,并没有把池子里的uploadSuccess
删掉,所以之后会触发与点击次数同等多的$on
解决
在每次
$on
前,先$off
,清除uploadSuccess
,再重新添加$on
The text was updated successfully, but these errors were encountered: