Currently, I am attempting to make use of the reference "index" located within
<tr v-for="(note, index) in noteList" v-bind:key="index"
in order to call shareToPublic(index). The method selectedID() allows for the selection of the index and retrieval of the current ID number. Upon clicking the Share button, it should redirect me to a page displaying the content selected based on the ID.
<template>
<div>
<button class="btn-delete" @click="shareToPublic(index)">Share</button>
<tbody>
<tr v-for="(note, index) in noteList"
v-bind:key="index"
v-if="note.workspace_id === currentWorkspace"
@dblclick="getNote(note.id)"
@click="selectedId(index)" >
<td>{{ note.title }}</td>
<button type="submit" @click="deletePage(note.id, index)">Delete</button>
</tr>
</div>
</template>
<script lang="ts">
@Componet
export default class ValueHub extends Vue {
private selectedId(index: number): number {
return this.noteList[index].id
}
async shareToPublic(index: number){
const numberToString = this.selectedId(index).toString()
await this.$router.push({name: 'PublicContent', params: {id: numberToString}});
}
}
</script>