import { jsx, jsxs, Fragment } from 'solid-jsx/jsx-runtime';

/*@jsxRuntime automatic @jsxImportSource solid-jsx*/
const toc = [];
function _createMdxContent(props) {
  const _components = Object.assign({
    p: "p",
    code: "code",
    pre: "pre",
    span: "span"
  }, props.components);
  return jsxs(Fragment, {
    children: [jsxs(_components.p, {
      children: ["如果你想遍历一个列表，", jsx(_components.code, {
        children: "<For>"
      }), " 组件是遍历任何非原始值数组的最佳方式。它通过引用自动键引用，以便在数据更新时对其进行优化以更新或移动行而不是重新创建它们。", jsx(_components.code, {
        children: "<For>"
      }), " 的回调函数是非跟踪的，并传递数据项和索引 Signal。"]
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-jsx",
        children: ["<", jsx(_components.span, {
          className: "hljs-title class_",
          children: "For"
        }), " each={", jsx(_components.span, {
          className: "hljs-title function_",
          children: "cats"
        }), "()}>\n  {", jsxs(_components.span, {
          className: "hljs-function",
          children: ["(", jsx(_components.span, {
            className: "hljs-params",
            children: "cat, i"
          }), ") =>"]
        }), " (\n    ", jsxs(_components.span, {
          className: "xml",
          children: [jsxs(_components.span, {
            className: "hljs-tag",
            children: ["<", jsx(_components.span, {
              className: "hljs-name",
              children: "li"
            }), ">"]
          }), "\n      ", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["<", jsx(_components.span, {
              className: "hljs-name",
              children: "a"
            }), " ", jsx(_components.span, {
              className: "hljs-attr",
              children: "target"
            }), "=", jsx(_components.span, {
              className: "hljs-string",
              children: "\"_blank\""
            }), " ", jsx(_components.span, {
              className: "hljs-attr",
              children: "href"
            }), "=", jsx(_components.span, {
              className: "hljs-string",
              children: "{"
            }), "`", jsx(_components.span, {
              className: "hljs-attr",
              children: "https:"
            }), "//", jsx(_components.span, {
              className: "hljs-attr",
              children: "www.youtube.com"
            }), "/", jsx(_components.span, {
              className: "hljs-attr",
              children: "watch"
            }), "?", jsx(_components.span, {
              className: "hljs-attr",
              children: "v"
            }), "=", jsx(_components.span, {
              className: "hljs-string",
              children: "${cat.id}"
            }), "`}>"]
          }), "\n        {i() + 1}: {cat.name}\n      ", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["</", jsx(_components.span, {
              className: "hljs-name",
              children: "a"
            }), ">"]
          }), "\n    ", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["</", jsx(_components.span, {
              className: "hljs-name",
              children: "li"
            }), ">"]
          })]
        }), "\n  )}\n</", jsx(_components.span, {
          className: "hljs-title class_",
          children: "For"
        }), ">\n"]
      })
    }), "\n", jsxs(_components.p, {
      children: [jsx(_components.code, {
        children: "index"
      }), " 是一个 Signal，因此它可以在移动行时独立更新。数据项不是 Signal，因为更改将意味着新引用并会导致创建新行。进行嵌套更新的方法是创建嵌套 Signal 或使用 Solid 的 Store 代理。"]
    }), "\n", jsxs(_components.p, {
      children: ["你还可以使用 ", jsx(_components.code, {
        children: "<For>"
      }), " 来迭代其他不是数组的可迭代对象，方法是使用类似 ", jsx(_components.code, {
        children: "Object.keys"
      }), " 的方法或简单地扩展到类似 ", jsx(_components.code, {
        children: "[...iterable]"
      }), " 的数组中。"]
    })]
  });
}
function MDXContent(props = {}) {
  const {wrapper: MDXLayout} = props.components || ({});
  return MDXLayout ? jsx(MDXLayout, Object.assign({}, props, {
    children: jsx(_createMdxContent, props)
  })) : _createMdxContent(props);
}

export { MDXContent as default, toc };
//# sourceMappingURL=lesson-22728603.js.map
