"这是我的前端代码:\n<div class="Products">\n
\n <tr th:each="product, productStat : ${indexProducts}" th:if="${productStat.index % 3 == 0}">\n <td th:attr="data-product-name=${product.name}" @click="getDialogData(product.name)">\n <el-image class="ProductImage" th:src="${product.imgUrl}" :fit="'cover'">\n \n <span class="ProductName" th:text="${product.name}">product-name\n \n <td @click="getDialogData(indexProducts[productStat.index + 1].name)">\n <el-image class="ProductImage" th:src="${product.imgUrl}" :fit="cover">\n \n <span class="ProductName" th:text="${indexProducts[productStat.index + 1].name}">product-name\n \n <td @click="getDialogData(indexProducts[productStat.index + 2].name)">\n <el-image class="ProductImage" th:src="${product.imgUrl}" :fit="cover">\n \n <span class="ProductName" th:text="${indexProducts[productStat.index + 2].name}">product-name\n \n \n
\n <el-button type="primary" @click="dialogVisible = true">Click\n <el-dialog title="Tips" v-model="dialogVisible">\n <div class="dialog">\n <div class="dialogLeft">\n <el-image class="dialogImage" src="" :fit="cover">\n \n
\n <div class="dialogRight">\n \n
\n \n
\n\n我希望在点击td时,可以调用书写在vue应用中定义的方法getDialogData,但当我点击时,参数并没有传递到此方法中,我该怎么做\n\n在你的代码中,你使用了@click来绑定点击事件,但是你没有正确地传递参数到方法中。\n\n可以尝试以下修改:\n\n1. 在点击事件绑定中,使用v-bind来传递参数。修改点击事件绑定如下:\n\n
html\n@click=\"getDialogData(product.name)\"\n\n\n2. 在vue应用中定义方法getDialogData,并接收参数。在vue实例中添加以下代码:\n\n
javascript\nmethods: {\n getDialogData(productName) {\n // 在这里处理点击事件的逻辑\n console.log(productName);\n }\n}\n\n\n这样,当你点击td时,getDialogData方法将会接收到对应的产品名称作为参数。你可以在getDialogData方法中处理点击事件的逻辑。\n