2π
β
It does not make much sense returning things on event handlers. It would be better in my opinion to pass the whole object and modify it, as follow:
<div v-show="id" v-for="(entry, index) in model.$.tokens" :key="'current' + index">
<input type="text" v-model="entry.title">
<input type="text" v-model="entry.token">
<button type="button" @click="generate(entry)">Generate random token</button>
</div>
generate(entry) {
entry.token = Math.random().toString(36).slice(2);
}
0π
Your passing and returning value
generate(payload) {
token = String(payload) + Math.random().toString(36).slice(2);
return token;
}
Source:stackexchange.com