VUEJS循环组件并立即获取发射数据
我循环一个孩子的组件,该组件已发出数据并传递给父母的本地数据,但我的期望结果不是我得到的。它应该以这种增量为单位。示例
Index Total
0 5
1 7
2 10
3 12
在这里我的代码:
<template>
<div>
<div v-for="data, index in myArr">
<child-block-1
:key="index"
:data="data"
@emittedData="total += $event"
/>
<child-block-2 v-if="total > 10" />
</div>
</div>
</template>
total
数据将添加发出的数据,但是当我检查总数时,总计总数始终为12。而不是增量。
还有其他解决方案可以得到我的预期结果吗?
I loop a child components that has emitted data and pass to local data in parent but my expectation result is not what i get. It should be in incremental like this. Example
Index Total
0 5
1 7
2 10
3 12
here my code:
<template>
<div>
<div v-for="data, index in myArr">
<child-block-1
:key="index"
:data="data"
@emittedData="total += $event"
/>
<child-block-2 v-if="total > 10" />
</div>
</div>
</template>
The total
data will add the emitted data, but when i check the total it will always the overall total 12. not the incremental.
Is there any other solution for this to get what my expected result ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论