在 vuejs 中单击列表 table 中的名称时切换页面?

Switch page when clicking on name in list table in vuejs?

我正在用vuejs制作列表页面。现在我遇到了如下问题:

<template>
    <vue-good-table
            :columns="columns"
            :rows="row"
            :search-options="{
              enabled: true,
              externalQuery: searchTerm,
            }"
    </vue-good-table>
</template>
<script>
    data() {
      return: {
         row: [];
         columns: [
        {
          label: "Name",
          field: "name",
        },
        {
          label: "Price",
          field: "price",
        },
        {
          label: "Quantity",
          field: "quantity",
        },
      ],
      }
    },
    created() {
       axios
          .get("/project/api/list")
          .then((res) => {
              this.rows = res.data;
          })
    }
</script>

我希望当我点击名称 samsung 或 iphone 时,它将转到该产品详细信息页面。

路线详情产品:

export default [{
        path: '/detail/product/:id',
        name: 'detail-product',
        component: () =>
            import ('@/views/product/list.vue'),
        meta: {
            resource: 'PRODUCT',
        },
    }, ]

任何想法请帮助我..谢谢。

尝试将事件 @on-row-click 添加到您的 table:

<vue-good-table
  :columns="columns"
  :rows="row"
  :search-options="{
    enabled: true,
    externalQuery: searchTerm,
  }"
  @on-row-click="onRowClick"
</vue-good-table>

然后在方法路由到详情页面:

methods: {
  onRowClick(params) {
    this.$router.push('/detail/product/' + params.row.id)
  }
}