@click="$router.push({ path: 'index/edit', query: { id: scope.row.id } })"错在哪
时间: 2024-05-01 21:17:17 浏览: 61
这段代码没有明确指定`$router`是哪个对象,因此无法确定`$router`是否存在以及是否可以被调用。正确的做法是在组件中引入`$router`,例如:
```
import { mapActions } from 'vuex'
export default {
methods: {
...mapActions(['edit']),
handleEdit(scope) {
this.edit(scope.row.id)
this.$router.push({ path: 'index/edit', query: { id: scope.row.id } })
}
}
}
```
这里假设组件已经引入了`mapActions`函数,以及在`actions`中定义了`edit`方法。
阅读全文