【发布时间】:2021-12-07 00:29:26
【问题描述】:
我在v-for 中有一个v-for。单击我选择的dropdown-item 后,我将数据传递给我的methods - 当然,这很好用。
但现在我需要在我的方法中的另一个函数中使用确切的 itemDropdown.ID...
我是否必须在方法之间传递数据,或者我该如何解决?
谢谢!
<div v-for="(item, index) in json" :key="index">
<b-dropdown text="Selection" right>
<b-dropdown-item v-for="(itemDropdown, indexDropdown) in json2" :key="indexDropdown" @click="inputDropdown(itemDropdown.ID)">{{itemDropdown.Name}}</b-dropdown-item>
</b-dropdown>
</div>
methods: {
inputDropdown(ID) {
//Some code
},
anotherFunction(here I need this itemDropdown.ID as well!)
//Do some code too
}
}
【问题讨论】:
-
你能在 inputDropdown() 中调用 anotherFunction() 吗?是不是搞砸了你的逻辑?
-
不清楚您的问题是什么...您如何调用
anotherFuntion()?如果您从inputDropdown()调用它,最明显的方法是传递ID,因为它已经在范围内
标签: javascript vue.js vuejs2