{"id":23669,"date":"2024-11-21T11:29:24","date_gmt":"2024-11-21T03:29:24","guid":{"rendered":"https:\/\/fwq.ai\/blog\/23669\/"},"modified":"2024-11-21T11:29:24","modified_gmt":"2024-11-21T03:29:24","slug":"%e5%9c%a8thinkphp6%e4%b8%ad%e4%bd%bf%e7%94%a8bootstrap%e6%a1%86%e6%9e%b6","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/23669\/","title":{"rendered":"\u5728ThinkPHP6\u4e2d\u4f7f\u7528Bootstrap\u6846\u67b6"},"content":{"rendered":"<p>\u968f\u7740web\u5f00\u53d1\u6280\u672f\u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u5f00\u53d1\u8005\u5c06\u76ee\u5149\u6295\u5411\u4e86\u524d\u7aef\u6846\u67b6\u3002\u6846\u67b6\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u5f00\u6e90\u6846\u67b6\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u6784\u5efa\u7f8e\u89c2\u7684\u54cd\u5e94\u5f0fweb\u754c\u9762\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u57286\u4e2d\u4f7f\u7528bootstrap\u6846\u67b6\u3002<\/p>\n<p>1.\u4f7f\u7528Composer\u5b89\u88c5Bootstrap<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528Composer\u8fdb\u884c\u5b89\u88c5\u3002\u5728ThinkPHP6\u7684\u5e94\u7528\u76ee\u5f55\u4e0b\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>composer require twbs\/bootstrap<\/p>\n<p>\u8fd9\u5c06\u4f1a\u5b89\u88c5Bootstrap\u6846\u67b6\u4ee5\u53ca\u5b83\u7684\u6240\u6709\u4f9d\u8d56\u9879\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>2.\u5f15\u5165Bootstrap\u6587\u4ef6<\/p>\n<p>\u5728\u6211\u4eec\u7684\u5e94\u7528\u7a0b\u5e8f\u4e2d\u4f7f\u7528Bootstrap\uff0c\u6211\u4eec\u9700\u8981\u5728\u89c6\u56fe\u6587\u4ef6\u4e2d\u5f15\u5165\u5b83\u7684\u76f8\u5173\u6587\u4ef6\u3002\u5728ThinkPHP6\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528PHP\u7684\u52a0\u8f7d\u5668\u6765\u5f15\u5165\u8fd9\u4e9b\u6587\u4ef6\u3002<\/p>\n<p>\u5728\u6211\u4eec\u7684\u516c\u5171\u5e03\u5c40\u6587\u4ef6\uff08\u4f8b\u5982layout.blade.php\uff09\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre>\n\n\n    &lt;meta charset=\"UTF-8\"&gt;&lt;title&gt;@yield('title')&lt;\/title&gt;&lt;link href=\"%7B%7B%20asset('vendor\/bootstrap\/css\/bootstrap.min.css')%20%7D%7D\" rel=\"stylesheet\"&gt;\n@yield('content')\n&lt;script src=\"%7B%7B%20asset('vendor\/bootstrap\/js\/bootstrap.min.js')%20%7D%7D\"&gt;&lt;\/script&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5df2\u7ecf\u6dfb\u52a0\u4e86Bootstrap\u7684CSS\u548cJS\u6587\u4ef6\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528asset\u51fd\u6570\u6765\u5f15\u7528Composer\u5b89\u88c5\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u3002<\/p>\n<p>3.\u4f7f\u7528Bootstrap\u6837\u5f0f<\/p>\n<p>\u73b0\u5728\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u6211\u4eec\u7684\u5e94\u7528\u7a0b\u5e8f\u4e2d\u4f7f\u7528Bootstrap\u7684\u6837\u5f0f\u3002\u8ba9\u6211\u4eec\u6765\u770b\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u3002\u6211\u4eec\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aindex.blade.php\u7684\u89c6\u56fe\u6587\u4ef6\uff1a<\/p>\n<pre>@extends('layout')\n\n@section('title')\n    Home\n@endsection\n\n@section('content')\n    &lt;div class=\"container\"&gt;\n        &lt;div class=\"jumbotron\"&gt;\n            &lt;h1&gt;Welcome to my site!&lt;\/h1&gt;\n            &lt;p class=\"lead\"&gt;This is a simple example of how to use Bootstrap with ThinkPHP6.&lt;\/p&gt;\n            &lt;p&gt;&lt;a class=\"btn btn-lg btn-primary\" href=\"#\" role=\"button\"&gt;Learn more \u00bb&lt;\/a&gt;&lt;\/p&gt;\n        &lt;\/div&gt;\n    &lt;\/div&gt;\n@endsection<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u8fd9\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86Bootstrap\u7684jumbotron\u548cbtn\u7c7b\u3002\u8fd9\u4e9b\u7c7b\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u6f02\u4eae\u7684\u9875\u9762\uff0c\u800c\u4e0d\u9700\u8981\u7f16\u5199\u5927\u91cf\u7684\u81ea\u5b9a\u4e49CSS\u3002<\/p>\n<p>4.\u4f7f\u7528Bootstrap\u7ec4\u4ef6<\/p>\n<p>Bootstrap\u8fd8\u63d0\u4f9b\u4e86\u8bb8\u591a\u7ec4\u4ef6\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u6784\u5efaWeb\u5e94\u7528\u7a0b\u5e8f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u7ec4\u4ef6\uff1a<\/p>\n<ul>\n<li>\u8868\u5355\uff1a\u7528\u4e8e\u521b\u5efa\u5404\u79cd\u7c7b\u578b\u7684\u8868\u5355\u5143\u7d20\uff0c\u4f8b\u5982\u6587\u672c\u6846\u3001\u5355\u9009\u6309\u94ae\u3001\u591a\u9009\u6309\u94ae\u3001\u4e0b\u62c9\u6846\u7b49\u3002<\/li>\n<li>\u5bfc\u822a\u680f\uff1a\u7528\u4e8e\u521b\u5efa\u54cd\u5e94\u5f0f\u5bfc\u822a\u680f\uff0c\u652f\u6301\u4e0b\u62c9\u83dc\u5355\u548c\u5206\u9875\u3002<\/li>\n<li>\u6807\u7b7e\u9875\uff1a\u7528\u4e8e\u663e\u793a\u591a\u4e2a\u9875\u9762\u7684\u5185\u5bb9\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e2a\u6807\u7b7e\u6761\u6765\u5207\u6362\u9875\u9762\u3002<\/li>\n<li>\u6a21\u6001\u6846\uff1a\u7528\u4e8e\u521b\u5efa\u652f\u6301JavaScript\u7684\u5f39\u51fa\u7a97\u53e3\u3002<\/li>\n<li>Tooltip\uff1a\u7528\u4e8e\u521b\u5efa\u5de5\u5177\u63d0\u793a\u548c\u5f39\u51fa\u63d0\u793a\u6846\u3002<\/li>\n<\/ul>\n<p>\u5728ThinkPHP6\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u4f7f\u7528\u8fd9\u4e9b\u7ec4\u4ef6\u3002\u8ba9\u6211\u4eec\u6765\u770b\u770b\u4e00\u4e2a\u8868\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<pre><\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 Email Password Address Address 2 City State Choose&#8230; &#8230; Zip Check me out Sign in <\/p>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86Bootstrap\u7684\u8868\u5355\u7ec4\u4ef6\uff0c\u5305\u62ec\u6587\u672c\u6846\u3001\u4e0b\u62c9\u6846\u3001\u5355\u9009\u6309\u94ae\u548c\u590d\u9009\u6846\u3002<\/p>\n<p>\u603b\u7ed3<\/p>\n<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u4ecb\u7ecd\u4e86\u5982\u4f55\u5728ThinkPHP6\u4e2d\u6dfb\u52a0Bootstrap\u6846\u67b6\u3002\u6211\u4eec\u5b66\u4e60\u4e86\u5982\u4f55\u5f15\u5165Bootstrap\u6587\u4ef6\u3001\u4f7f\u7528\u6837\u5f0f\u548c\u7ec4\u4ef6\u521b\u5efa\u4e00\u4e2a\u6f02\u4eae\u7684Web\u5e94\u7528\u7a0b\u5e8f\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u67e5\u770bBootstrap\u5b98\u65b9\u6587\u6863\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5728ThinkPHP6\u4e2d\u4f7f\u7528Bootstrap\u6846\u67b6\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\u5f00\u53d1\u6280\u672f\u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u5f00\u53d1\u8005\u5c06\u76ee\u5149\u6295\u5411\u4e86\u524d\u7aef\u6846\u67b6\u3002\u6846\u67b6\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u5f00\u6e90\u6846\u67b6\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u6784\u5efa\u7f8e\u89c2\u7684\u54cd\u5e94\u5f0fweb\u754c\u9762\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u57286\u4e2d\u4f7f\u7528bootstrap\u6846\u67b6\u3002 1.\u4f7f\u7528Composer\u5b89\u88c5Bootstrap \u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528Composer\u8fdb\u884c\u5b89\u88c5\u3002\u5728ThinkPHP6\u7684\u5e94\u7528\u76ee\u5f55\u4e0b\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a composer require twbs\/bootstrap \u8fd9\u5c06\u4f1a\u5b89\u88c5Bootstrap\u6846\u67b6\u4ee5\u53ca\u5b83\u7684\u6240\u6709\u4f9d\u8d56\u9879\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b 2.\u5f15\u5165Bootstrap\u6587\u4ef6 \u5728\u6211\u4eec\u7684\u5e94\u7528\u7a0b\u5e8f\u4e2d\u4f7f\u7528Bootstrap\uff0c\u6211\u4eec\u9700\u8981\u5728\u89c6\u56fe\u6587\u4ef6\u4e2d\u5f15\u5165\u5b83\u7684\u76f8\u5173\u6587\u4ef6\u3002\u5728ThinkPHP6\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528PHP\u7684\u52a0\u8f7d\u5668\u6765\u5f15\u5165\u8fd9\u4e9b\u6587\u4ef6\u3002 \u5728\u6211\u4eec\u7684\u516c\u5171\u5e03\u5c40\u6587\u4ef6\uff08\u4f8b\u5982layout.blade.php\uff09\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a &lt;meta charset=&#8221;UTF-8&#8243;&gt;&lt;title&gt;@yield(&#8216;title&#8217;)&lt;\/title&gt;&lt;link href=&#8221;%7B%7B%20asset(&#8216;vendor\/bootstrap\/css\/bootstrap.min.css&#8217;)%20%7D%7D&#8221; rel=&#8221;stylesheet&#8221;&gt; @yield(&#8216;content&#8217;) &lt;script src=&#8221;%7B%7B%20asset(&#8216;vendor\/bootstrap\/js\/bootstrap.min.js&#8217;)%20%7D%7D&#8221;&gt;&lt;\/script&gt; \u767b\u5f55\u540e\u590d\u5236 \u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5df2\u7ecf\u6dfb\u52a0\u4e86Bootstrap\u7684CSS\u548cJS\u6587\u4ef6\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528asset\u51fd\u6570\u6765\u5f15\u7528Composer\u5b89\u88c5\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u3002 3.\u4f7f\u7528Bootstrap\u6837\u5f0f \u73b0\u5728\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u6211\u4eec\u7684\u5e94\u7528\u7a0b\u5e8f\u4e2d\u4f7f\u7528Bootstrap\u7684\u6837\u5f0f\u3002\u8ba9\u6211\u4eec\u6765\u770b\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u3002\u6211\u4eec\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aindex.blade.php\u7684\u89c6\u56fe\u6587\u4ef6\uff1a @extends(&#8216;layout&#8217;) @section(&#8216;title&#8217;) Home @endsection @section(&#8216;content&#8217;) &lt;div class=&#8221;container&#8221;&gt; &lt;div class=&#8221;jumbotron&#8221;&gt; &lt;h1&gt;Welcome to my site!&lt;\/h1&gt; &lt;p class=&#8221;lead&#8221;&gt;This is a simple example of how to use Bootstrap with ThinkPHP6.&lt;\/p&gt; &lt;p&gt;&lt;a class=&#8221;btn btn-lg btn-primary&#8221; href=&#8221;#&#8221; role=&#8221;button&#8221;&gt;Learn more [&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-23669","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23669","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=23669"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23669\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=23669"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=23669"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=23669"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}