如何在vue js中找到表格的列和行?

时间:2019-12-09 06:00:23

标签: c# jquery vue.js model-view-controller razor

这些是我一直在使用el =“ #app”的示例代码。


<div id="app">
      <div id="customertable" style=" overflow:auto !important;height:100% ">
            <table class="table" id="table">
                <thead id="customerheadertable">
                    <tr>
                        <th scope="col" style="width:1%"></th>
                        <th scope="col" style="width:10%">Customer ID</th>
                        <th scope="col" style="width:30%">Customer Name</th>
                        <th scope="col" style="width:30%">Address</th>
                        <th scope="col" style="width:10%">Contact Number</th>
                        <th scope="col" style="width:10%">Actions</th>

                    </tr>
                </thead>
                <tbody id="custtomerbodytable">
                    <tr>
                        <td>1</td>
                        <td ref="customerid">(CUSTOMER ID)</td>
                        <td>(Name)</td>
                        <td>(Address)</td>
                        <td>(MOBILE NUMBER)</td>
                        <td>
                            <b-dropdown text="•••" class="activity_button">
                            <b-dropdown-item href="#" @@click="dropdown(event)" class="dropdown">View</b-dropdown-item>
                            </b-dropdown>
                        </td>
                    </tr>
                    <tr>
                        <td>2</td>
                        <td ref="customerid">(CUSTOMER ID)</td>
                        <td>(Name)</td>
                        <td>(Address)</td>
                        <td>(MOBILE NUMBER)</td>
                        <td>
                            <b-dropdown text="•••" class="activity_button">
                            <b-dropdown-item href="#" @@click="dropdown(event)" class="dropdown">View</b-dropdown-item>
                            </b-dropdown>
                        </td>
                    </tr>
                </tbody>
          </table>
      </div>
 </div>

使用Vue JS单击@@ click =“ dropdown(event)”时,如何获取ref =“ customerid”的最接近值。

就像jquery。

$(".dropdown").click(function() {
 $(this).closest('tr').find('td:eq(1)').html().trim();
});

------ This is the sample output

0 个答案:

没有答案