{"id":23689,"date":"2024-11-21T11:23:58","date_gmt":"2024-11-21T03:23:58","guid":{"rendered":"https:\/\/fwq.ai\/blog\/23689\/"},"modified":"2024-11-21T11:23:58","modified_gmt":"2024-11-21T03:23:58","slug":"%e5%9c%a8thinkphp6%e4%b8%ad%e4%bd%bf%e7%94%a8bootstrap%e5%ae%9e%e7%8e%b0%e5%bf%ab%e9%80%9f%e5%bc%80%e5%8f%91%e9%a1%b9%e7%9b%ae","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/23689\/","title":{"rendered":"\u5728ThinkPHP6\u4e2d\u4f7f\u7528Bootstrap\u5b9e\u73b0\u5feb\u901f\u5f00\u53d1\u9879\u76ee"},"content":{"rendered":"<p>\u968f\u7740web\u5e94\u7528\u7684\u4e0d\u65ad\u53d1\u5c55\uff0cweb\u5f00\u53d1\u6846\u67b6\u6210\u4e3a\u4e86\u5f00\u53d1web\u5e94\u7528\u7684\u5fc5\u5907\u5de5\u5177\u3002\u5176\u4e2d\uff0c6\u662f\u4e00\u6b3e\u4f18\u79c0\u7684php\u5f00\u53d1\u6846\u67b6\uff0c\u5b83\u5177\u6709\u9ad8\u6027\u80fd\u3001\u6613\u4e8e\u4e0a\u624b\u7b49\u7279\u70b9\uff0c\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8eweb\u5e94\u7528\u5f00\u53d1\u3002\u800c\u5219\u662f\u4e00\u6b3e\u6d41\u884c\u7684\u524d\u7aef\u6846\u67b6\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684ui\u7ec4\u4ef6\u548c\u6837\u5f0f\u89c4\u8303\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u6784\u5efa\u6f02\u4eae\u7684web\u754c\u9762\u3002<\/p>\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728ThinkPHP6\u4e2d\u4f7f\u7528Bootstrap\u6765\u5b9e\u73b0\u5feb\u901f\u5f00\u53d1\u9879\u76ee\u3002\u5e0c\u671b\u8bfb\u8005\u80fd\u591f\u901a\u8fc7\u672c\u6587\uff0c\u5feb\u901f\u638c\u63e1\u76f8\u5173\u6280\u672f\uff0c\u5e76\u7528\u4e8e\u81ea\u5df1\u7684Web\u5e94\u7528\u5f00\u53d1\u4e2d\u3002<\/p>\n<p>\u4e00\u3001\u5b89\u88c5Bootstrap<\/p>\n<p>ThinkPHP6\u4f7f\u7528Composer\u6765\u7ba1\u7406\u4f9d\u8d56\u5e93\uff0c\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7Composer\u6765\u5b89\u88c5Bootstrap\u3002\u6253\u5f00\u547d\u4ee4\u884c\u7ec8\u7aef\uff0c\u8fdb\u5165\u5230\u9879\u76ee\u6839\u76ee\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>composer require twbs\/bootstrap<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u4f1a\u4e0b\u8f7d\u5e76\u5b89\u88c5Bootstrap\u5230vendor\/twbs\/bootstrap\u76ee\u5f55\u4e2d\u3002\u5728\u8fd9\u4e2a\u76ee\u5f55\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u627e\u5230\u6240\u6709Bootstrap\u9700\u8981\u7684CSS\u3001JS\u548c\u5b57\u4f53\u6587\u4ef6\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u4e8c\u3001\u5728\u89c6\u56fe\u4e2d\u4f7f\u7528Bootstrap<\/p>\n<p>\u5b89\u88c5\u5b8cBootstrap\u4e4b\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u89c6\u56fe\u4e2d\u4f7f\u7528Bootstrap\u63d0\u4f9b\u7684UI\u7ec4\u4ef6\u548c\u6837\u5f0f\u89c4\u8303\u6765\u6784\u5efaWeb\u754c\u9762\u3002\u5728ThinkPHP6\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06Bootstrap\u7684CSS\u548cJS\u6587\u4ef6\u5f15\u5165\u5230\u5e03\u5c40\u6587\u4ef6layout.html\u4e2d\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u5728\u5b50\u6a21\u677f\u4e2d\u76f4\u63a5\u4f7f\u7528Bootstrap\u76f8\u5173\u7684\u7c7b\u548c\u6837\u5f0f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5e03\u5c40\u6587\u4ef6\u793a\u4f8b\uff1a<\/p>\n<pre>\n\n\n    &lt;meta charset=\"UTF-8\"&gt;&lt;title&gt;{% block title %}{% endblock %}&lt;\/title&gt;\n    {% block style %}\n    &lt;link rel=\"stylesheet\" href=\"\/vendor\/twbs\/bootstrap\/dist\/css\/bootstrap.min.css\"&gt;\n    {% endblock %}\n\n\n    {% block content %}{% endblock %}\n    {% block script %}\n    &lt;script src=\"\/vendor\/twbs\/bootstrap\/dist\/js\/bootstrap.min.js\"&gt;&lt;\/script&gt;\n    {% endblock %}\n\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u8fd9\u4e2a\u5e03\u5c40\u6587\u4ef6\u4e2d\uff0c\u6211\u4eec\u5f15\u5165\u4e86Bootstrap\u7684CSS\u548cJS\u6587\u4ef6\u3002\u5728\u5b50\u6a21\u677f\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u7ee7\u627f\u8fd9\u4e2a\u5e03\u5c40\u6587\u4ef6\u6765\u4f7f\u7528Bootstrap\u63d0\u4f9b\u7684UI\u7ec4\u4ef6\u548c\u6837\u5f0f\u89c4\u8303\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5b50\u6a21\u677f\u793a\u4f8b\uff1a<\/p>\n<pre>{% extends 'layout.html' %}\n\n{% block title %}Hello World{% endblock %}\n\n{% block content %}\n&lt;div class=\"jumbotron\"&gt;\n  &lt;h1&gt;Hello, world!&lt;\/h1&gt;\n  &lt;p&gt;This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.&lt;\/p&gt;\n  &lt;p&gt;&lt;a class=\"btn btn-primary btn-lg\" href=\"#\" role=\"button\"&gt;Learn more&lt;\/a&gt;&lt;\/p&gt;\n&lt;\/div&gt;\n{% endblock %}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u8fd9\u4e2a\u5b50\u6a21\u677f\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86Bootstrap\u63d0\u4f9b\u7684jumbotron\u7ec4\u4ef6\u6765\u5c55\u793a\u9875\u9762\u6807\u9898\u548c\u5185\u5bb9\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u5728ThinkPHP6\u4e2d\u4f7f\u7528Bootstrap\u6765\u6784\u5efaWeb\u754c\u9762\u3002<\/p>\n<p>\u4e09\u3001\u4f7f\u7528Bootstrap\u8868\u5355\u7ec4\u4ef6<\/p>\n<p>\u5728Web\u5e94\u7528\u5f00\u53d1\u4e2d\uff0c\u8868\u5355\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u7ec4\u4ef6\u3002Bootstrap\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u8868\u5355\u7ec4\u4ef6\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u6784\u5efa\u6f02\u4eae\u7684\u8868\u5355\u754c\u9762\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u8868\u5355\u793a\u4f8b\uff1a<\/p>\n<pre><\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 Email address<br \/>\n<small>We&#8217;ll never share your email with anyone else.<\/small> Password Check me out Submit <\/p>\n<p>\u5728\u8fd9\u4e2a\u8868\u5355\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86Bootstrap\u63d0\u4f9b\u7684form-group\u3001form-control\u548cform-check\u7b49\u6837\u5f0f\u7c7b\u6765\u6784\u5efa\u8868\u5355\u7ec4\u4ef6\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u6784\u5efa\u6f02\u4eae\u7684\u8868\u5355\u754c\u9762\u3002<\/p>\n<p>\u56db\u3001\u4f7f\u7528Bootstrap\u6a21\u6001\u6846<\/p>\n<p>\u6a21\u6001\u6846\u662fWeb\u754c\u9762\u4e2d\u5e38\u7528\u7684\u4ea4\u4e92\u7ec4\u4ef6\uff0c\u53ef\u4ee5\u7528\u4e8e\u786e\u8ba4\u5f39\u7a97\u3001\u8b66\u544a\u5f39\u7a97\u3001\u4fee\u6539\u5f39\u7a97\u7b49\u573a\u666f\u3002Bootstrap\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u6a21\u6001\u6846\u7ec4\u4ef6\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u6784\u5efa\u6f02\u4eae\u7684\u6a21\u6001\u6846\u754c\u9762\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6a21\u6001\u6846\u793a\u4f8b\uff1a<\/p>\n<pre>&lt;!-- Button trigger modal --&gt;\n&lt;button type=\"button\" class=\"btn btn-primary\" data-toggle=\"modal\" data-target=\"#exampleModal\"&gt;\n  Launch demo modal\n&lt;\/button&gt;\n\n&lt;!-- Modal --&gt;\n&lt;div class=\"modal fade\" id=\"exampleModal\" tabindex=\"-1\" aria-labelledby=\"exampleModalLabel\" aria-hidden=\"true\"&gt;\n  &lt;div class=\"modal-dialog\"&gt;\n    &lt;div class=\"modal-content\"&gt;\n      &lt;div class=\"modal-header\"&gt;\n        &lt;h5 class=\"modal-title\" id=\"exampleModalLabel\"&gt;Modal title&lt;\/h5&gt;\n        &lt;button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"&gt;\n          &lt;span aria-hidden=\"true\"&gt;\u00d7&lt;\/span&gt;\n        &lt;\/button&gt;\n      &lt;\/div&gt;\n      &lt;div class=\"modal-body\"&gt;\n        ...\n      &lt;\/div&gt;\n      &lt;div class=\"modal-footer\"&gt;\n        &lt;button type=\"button\" class=\"btn btn-secondary\" data-dismiss=\"modal\"&gt;Close&lt;\/button&gt;\n        &lt;button type=\"button\" class=\"btn btn-primary\"&gt;Save changes&lt;\/button&gt;\n      &lt;\/div&gt;\n    &lt;\/div&gt;\n  &lt;\/div&gt;\n&lt;\/div&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u8fd9\u4e2a\u6a21\u6001\u6846\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86Bootstrap\u63d0\u4f9b\u7684modal\u3001modal-dialog\u3001modal-content\u3001modal-header\u3001modal-body\u548cmodal-footer\u7b49\u6837\u5f0f\u7c7b\u6765\u6784\u5efa\u6a21\u6001\u6846\u7ec4\u4ef6\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u6784\u5efa\u6f02\u4eae\u7684\u6a21\u6001\u6846\u754c\u9762\u3002<\/p>\n<p>\u603b\u7ed3<\/p>\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u4ecb\u7ecd\u4e86\u5982\u4f55\u5728ThinkPHP6\u4e2d\u4f7f\u7528Bootstrap\u6765\u5b9e\u73b0\u5feb\u901f\u5f00\u53d1\u9879\u76ee\u3002\u9996\u5148\uff0c\u6211\u4eec\u901a\u8fc7Composer\u5b89\u88c5\u4e86Bootstrap\u5e93\uff0c\u7136\u540e\u5728\u5e03\u5c40\u6587\u4ef6\u4e2d\u5f15\u5165\u4e86Bootstrap\u7684CSS\u548cJS\u6587\u4ef6\u3002\u6700\u540e\uff0c\u6211\u4eec\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528Bootstrap\u8868\u5355\u7ec4\u4ef6\u548c\u6a21\u6001\u6846\u7ec4\u4ef6\u6765\u6784\u5efaWeb\u754c\u9762\u3002<\/p>\n<p>\u901a\u8fc7\u5b66\u4e60\u672c\u6587\uff0c\u8bfb\u8005\u53ef\u4ee5\u638c\u63e1\u5728ThinkPHP6\u4e2d\u4f7f\u7528Bootstrap\u7684\u76f8\u5173\u6280\u672f\uff0c\u5feb\u901f\u6784\u5efa\u6f02\u4eae\u7684Web\u754c\u9762\u3002\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u8fdb\u4e00\u6b65\u63a2\u7d22Bootstrap\u7684\u5176\u4ed6\u529f\u80fd\u548c\u7279\u6027\uff0c\u6765\u6ee1\u8db3\u4e0d\u540c\u7684\u9700\u6c42\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5728ThinkPHP6\u4e2d\u4f7f\u7528Bootstrap\u5b9e\u73b0\u5feb\u901f\u5f00\u53d1\u9879\u76ee\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u968f\u7740web\u5e94\u7528\u7684\u4e0d\u65ad\u53d1\u5c55\uff0cweb\u5f00\u53d1\u6846\u67b6\u6210\u4e3a\u4e86\u5f00\u53d1web\u5e94\u7528\u7684\u5fc5\u5907\u5de5\u5177\u3002\u5176\u4e2d\uff0c6\u662f\u4e00\u6b3e\u4f18\u79c0\u7684php\u5f00\u53d1\u6846\u67b6\uff0c\u5b83\u5177\u6709\u9ad8\u6027\u80fd\u3001\u6613\u4e8e\u4e0a\u624b\u7b49\u7279\u70b9\uff0c\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8eweb\u5e94\u7528\u5f00\u53d1\u3002\u800c\u5219\u662f\u4e00\u6b3e\u6d41\u884c\u7684\u524d\u7aef\u6846\u67b6\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684ui\u7ec4\u4ef6\u548c\u6837\u5f0f\u89c4\u8303\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u6784\u5efa\u6f02\u4eae\u7684web\u754c\u9762\u3002 \u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728ThinkPHP6\u4e2d\u4f7f\u7528Bootstrap\u6765\u5b9e\u73b0\u5feb\u901f\u5f00\u53d1\u9879\u76ee\u3002\u5e0c\u671b\u8bfb\u8005\u80fd\u591f\u901a\u8fc7\u672c\u6587\uff0c\u5feb\u901f\u638c\u63e1\u76f8\u5173\u6280\u672f\uff0c\u5e76\u7528\u4e8e\u81ea\u5df1\u7684Web\u5e94\u7528\u5f00\u53d1\u4e2d\u3002 \u4e00\u3001\u5b89\u88c5Bootstrap ThinkPHP6\u4f7f\u7528Composer\u6765\u7ba1\u7406\u4f9d\u8d56\u5e93\uff0c\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7Composer\u6765\u5b89\u88c5Bootstrap\u3002\u6253\u5f00\u547d\u4ee4\u884c\u7ec8\u7aef\uff0c\u8fdb\u5165\u5230\u9879\u76ee\u6839\u76ee\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a composer require twbs\/bootstrap \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u5c06\u4f1a\u4e0b\u8f7d\u5e76\u5b89\u88c5Bootstrap\u5230vendor\/twbs\/bootstrap\u76ee\u5f55\u4e2d\u3002\u5728\u8fd9\u4e2a\u76ee\u5f55\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u627e\u5230\u6240\u6709Bootstrap\u9700\u8981\u7684CSS\u3001JS\u548c\u5b57\u4f53\u6587\u4ef6\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4e8c\u3001\u5728\u89c6\u56fe\u4e2d\u4f7f\u7528Bootstrap \u5b89\u88c5\u5b8cBootstrap\u4e4b\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u89c6\u56fe\u4e2d\u4f7f\u7528Bootstrap\u63d0\u4f9b\u7684UI\u7ec4\u4ef6\u548c\u6837\u5f0f\u89c4\u8303\u6765\u6784\u5efaWeb\u754c\u9762\u3002\u5728ThinkPHP6\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06Bootstrap\u7684CSS\u548cJS\u6587\u4ef6\u5f15\u5165\u5230\u5e03\u5c40\u6587\u4ef6layout.html\u4e2d\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u5728\u5b50\u6a21\u677f\u4e2d\u76f4\u63a5\u4f7f\u7528Bootstrap\u76f8\u5173\u7684\u7c7b\u548c\u6837\u5f0f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5e03\u5c40\u6587\u4ef6\u793a\u4f8b\uff1a &lt;meta charset=&#8221;UTF-8&#8243;&gt;&lt;title&gt;{% block title %}{% endblock %}&lt;\/title&gt; {% block style %} &lt;link rel=&#8221;stylesheet&#8221; href=&#8221;\/vendor\/twbs\/bootstrap\/dist\/css\/bootstrap.min.css&#8221;&gt; {% endblock %} {% block content %}{% endblock %} {% block script %} &lt;script src=&#8221;\/vendor\/twbs\/bootstrap\/dist\/js\/bootstrap.min.js&#8221;&gt;&lt;\/script&gt; {% endblock %} \u767b\u5f55\u540e\u590d\u5236 \u5728\u8fd9\u4e2a\u5e03\u5c40\u6587\u4ef6\u4e2d\uff0c\u6211\u4eec\u5f15\u5165\u4e86Bootstrap\u7684CSS\u548cJS\u6587\u4ef6\u3002\u5728\u5b50\u6a21\u677f\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u7ee7\u627f\u8fd9\u4e2a\u5e03\u5c40\u6587\u4ef6\u6765\u4f7f\u7528Bootstrap\u63d0\u4f9b\u7684UI\u7ec4\u4ef6\u548c\u6837\u5f0f\u89c4\u8303\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5b50\u6a21\u677f\u793a\u4f8b\uff1a {% extends &#8216;layout.html&#8217; %} {% block title %}Hello World{% [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-23689","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23689","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=23689"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23689\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=23689"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=23689"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=23689"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}