我正在学习vuetify和vue js,我想知道当我点击我的treeview时如何获取参数:
的例子:
在控制台chrome与vue扩展我有:Vue事件更新:激活(这给了我元素的id在我的树视图)
我想比较函数中的参数来做一些操作当我点击树视图中的一个元素时,我怎么做呢
<v-treeview
v-if="userExists"
hoverable
open-on-click
@update:active="openRoute"
:items="items"
activatable>
</v-treeview>
和我写的函数
function openRoute () {
const routes = _.map(items, function (item) {
if (item.name === 'Structure') { // here I want to compare with the id
return item.routeName
}
})
const test = routes.toString()
context.root.$router.push({ name: routes })
}
谢谢你的帮助
您可以简单地将参数添加到函数中。例如:
function openRoute (emitedValue) {
console.log(emitedValue);
const routes = _.map(items, function (item) {
if (item.name === 'Structure') { // here I want to compare with the id
return item.routeName
}
})
const test = routes.toString()
context.root.$router.push({ name: routes })
}