Reputation: 784
In the regular API I can get the key like this:
created()
{
console.log(this._.vnode.key);
}
But in the composition API, in setup(), 'this' is undefined. I tried to check the data and context properties, but can't find anything.
Upvotes: 3
Views: 1494
Reputation: 784
Figured it out:
import { getCurrentInstance } from "vue";
setup() {
const component = getCurrentInstance();
console.log(component.vnode.key);
}
Upvotes: 4