我正在尝试根据正确匹配的数组从嵌套数组中删除项目。
适用三个要求:
我构建了一个函数来递归地到达最深层次并根据 $match 数组过滤项目。
这是我的代码到目前为止的样子:
import * as lodash from "https://cdn.skypack.dev/lodash@4.17.21";
let filterRecursively = (arr, match) => {
// Recursively go to the deepest array we can find
arr.forEach(el => {
arr = el.children ? filterRecursively(el.children, match) : arr
});
// If we are at the deepest level we filter the items ...
if (arr[0] && arr[0].children === undefined) {
return _.filter(arr, (item) => {
return match.includes(item.name)
})
} else { // ... if not we …Run Code Online (Sandbox Code Playgroud) 使用新的 Inertia Laravel 堆栈 \xe2\x80\x93\xc2\xa0 如何观察路线变化?
\n我正在尝试做一些非常简单的事情,例如:
\nwatch: {\n route () {\n console.log('You changed route')\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n我一直无法找到这方面的任何信息。
\n