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 允许使用 JavaScript 来控制模板中的逻辑流。然而，如果没有虚拟 DOM，天真地使用诸如 ", jsx(_components.code, {
        children: "Array.prototype.map"
      }), " 之类的东西会在每次更新时很浪费地重新创建所有 DOM 节点。相反，Reactive 库使用模板工具是很常见。在 Solid 中，我们将其封装在组件中。"]
    }), "\n", jsxs(_components.p, {
      children: ["最基本的控制流是条件。Solid 的编译器足够聪明，可以优化处理三元组 (", jsx(_components.code, {
        children: "a ? b : c"
      }), ") 和布尔表达式 (", jsx(_components.code, {
        children: "a && b"
      }), ")。然而，使用 ", jsx(_components.code, {
        children: "<Show>"
      }), " 组件通常更简洁。"]
    }), "\n", jsx(_components.p, {
      children: "要仅显示正确的按钮来展示当前状态，请将 JSX 更新为："
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-jsx",
        children: ["<", jsx(_components.span, {
          className: "hljs-title class_",
          children: "Show"
        }), "\n  when={", jsx(_components.span, {
          className: "hljs-title function_",
          children: "loggedIn"
        }), "()}\n  fallback={", jsx(_components.span, {
          className: "hljs-function",
          children: "() =>"
        }), " ", jsxs(_components.span, {
          className: "xml",
          children: [jsxs(_components.span, {
            className: "hljs-tag",
            children: ["<", jsx(_components.span, {
              className: "hljs-name",
              children: "button"
            }), " ", jsx(_components.span, {
              className: "hljs-attr",
              children: "onClick"
            }), "=", jsx(_components.span, {
              className: "hljs-string",
              children: "{toggle}"
            }), ">"]
          }), "Log in", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["</", jsx(_components.span, {
              className: "hljs-name",
              children: "button"
            }), ">"]
          })]
        }), "}\n>\n  ", jsxs(_components.span, {
          className: "xml",
          children: [jsxs(_components.span, {
            className: "hljs-tag",
            children: ["<", jsx(_components.span, {
              className: "hljs-name",
              children: "button"
            }), " ", jsx(_components.span, {
              className: "hljs-attr",
              children: "onClick"
            }), "=", jsx(_components.span, {
              className: "hljs-string",
              children: "{toggle}"
            }), ">"]
          }), "Log out", jsxs(_components.span, {
            className: "hljs-tag",
            children: ["</", jsx(_components.span, {
              className: "hljs-name",
              children: "button"
            }), ">"]
          })]
        }), "\n</", jsx(_components.span, {
          className: "hljs-title class_",
          children: "Show"
        }), ">\n"]
      })
    }), "\n", jsxs(_components.p, {
      children: [jsx(_components.code, {
        children: "fallback"
      }), " 属性充当 ", jsx(_components.code, {
        children: "else"
      }), "，在传递给 ", jsx(_components.code, {
        children: "when"
      }), " 的条件不为 ", jsx(_components.code, {
        children: "true"
      }), " 时显示。"]
    }), "\n", jsx(_components.p, {
      children: "现在单击按钮将像你所期望的那样来回更改。"
    })]
  });
}
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-568942e0.js.map
