我正在尝试引用shareToPublic(index)<tr v-for="(note, index) in noteList" v-bind:key="index"
中的“索引” 。selectedID()方法选择索引并返回当前 ID 号。之后,当我单击“共享”按钮时,它应该将我带到一个页面,该页面显示从 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: numbrer){
const numberToString = this.selectedId(index).toString()
await this.$router.push({name: 'PublicContent', params: {id: numberToString}});
}
}
</script>