我正在使用 VueJS 做一個(gè)項(xiàng)目,我需要以下內(nèi)容:
使用 API 并獲取主頁(yè)中的用戶列表。
當(dāng)單擊用戶的按鈕時(shí),我需要重定向到另一個(gè)組件并在該組件中輸出該用戶的詳細(xì)信息(僅我單擊的用戶的詳細(xì)信息)。
這是顯示用戶信息的表格
<v-data-table hide-actions flat :headers="headers" :items="doctors"> <template v-slot:items="props"> <td>{{ props.index + 1 }}</td> <td>{{ props.item.profile.full_name }}</td> <td>{{ props.item.email }}</td> <td>{{ props.item.username }}</td> <td>{{ props.item.updated_at }}</td> <td> <v-btn outline small color="indigo" @click="view(props.item)"> <i class="fa fa-eye"></i> make payment </v-btn> </td> </template> <template v-slot:no-results> <h6 class="grey--text">No data available</h6> </template> </v-data-table>
視圖函數(shù)在方法中
view() { window.open(`/finance/pay-doctors/${item.id}`, "_blank"); },
我創(chuàng)建了一條動(dòng)態(tài)路線
{ path: '/finance/pay-doctors/:id', component: DoctorDetails}
無(wú)法創(chuàng)建 DoctorDetails 并顯示數(shù)據(jù)
我建議您首先嘗試使用路由器推送。
因此請(qǐng)使用
<script> export default { methods: { view(id) { this.$router.push({ path: `/finance/pay-doctors/${item.id}` }) } } } </script>
確保您的路由器已正確設(shè)置 感謝您的 Vue 開發(fā)工具,您擁有正確的狀態(tài)。
此外,請(qǐng)確保在 DoctorDetails
上有一些東西可以獲取用戶的數(shù)據(jù)。