<td v-for="user in users" :key="user._id">
<div>
<v-btn @click="printName" height="50" size="large" color="purple" >
{{ user.it_name.slice(0, 10) }}
</v-btn>
</div>
</td>
<script setup>
function printName(user) {
console.log(user._id.value);
}
</script>
the result is Cannot read properties of undefined (reading 'value' How to print in console user._id or user.it_name Thank
CodePudding user response:
To print the _id of the user in the printName function, you can pass the user object as an argument to the function in the onclick event.
<v-btn @click="printName(user)" height="50" size="large" color="purple">
{{ user.it_name.slice(0, 10) }}
</v-btn>
