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: [jsx(_components.p, {
      children: "在构建应用程序时，你需要拆分代码以获得更好的模块化和复用性。在 Solid 中，你可以通过创建组件达到你的目的。"
    }), "\n", jsx(_components.p, {
      children: "组件仅仅是函数，就像在之前的教程中写的那样。在父级 JSX 中，组件可以用标签展示，并在第一次渲染时执行。之后，组件函数再也不会被调用。相反，所有更新都由 Solid 的响应式系统接管，我们将在接下来的几节课中学习到。"
    }), "\n", jsxs(_components.p, {
      children: ["在下面例子中，我们将 ", jsx(_components.code, {
        children: "Nested"
      }), " 组件添加到我们的应用程序中。我们已经在另一个文件中定义了它，尽管你可以将多个组件放在同一个文件中。首先我们必须导入它。"]
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-js",
        children: [jsx(_components.span, {
          className: "hljs-keyword",
          children: "import"
        }), " ", jsx(_components.span, {
          className: "hljs-title class_",
          children: "Nested"
        }), " ", jsx(_components.span, {
          className: "hljs-keyword",
          children: "from"
        }), " ", jsx(_components.span, {
          className: "hljs-string",
          children: "\"./nested\""
        }), ";\n"]
      })
    }), "\n", jsx(_components.p, {
      children: "然后我们需要将它添加到我们的 JSX 中。在这种情况下，我们现在有 2 个要返回的元素，因此我们可以将它们包装在一个 Fragment 中。"
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-jsx",
        children: [jsx(_components.span, {
          className: "hljs-keyword",
          children: "function"
        }), " ", jsx(_components.span, {
          className: "hljs-title function_",
          children: "App"
        }), "(", jsx(_components.span, {
          className: "hljs-params"
        }), ") {\n  ", jsx(_components.span, {
          className: "hljs-keyword",
          children: "return"
        }), " (\n    ", jsxs(_components.span, {
          className: "xml",
          children: [jsx(_components.span, {
            className: "hljs-tag",
            children: "<>"
          }), "\n      ", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["<", jsx(_components.span, {
              className: "hljs-name",
              children: "h1"
            }), ">"]
          }), "This is a Header", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["</", jsx(_components.span, {
              className: "hljs-name",
              children: "h1"
            }), ">"]
          }), "\n      ", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["<", jsx(_components.span, {
              className: "hljs-name",
              children: "Nested"
            }), " />"]
          }), "\n    ", jsx(_components.span, {
            className: "hljs-tag",
            children: "</>"
          })]
        }), "\n  );\n}\n"]
      })
    })]
  });
}
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-e54a6383.js.map
