shi-tu.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <!DOCTYPE HTML>
  2. <html lang="" >
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  6. <title>视图 · GitBook</title>
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  8. <meta name="description" content="">
  9. <meta name="generator" content="GitBook 3.2.3">
  10. <link rel="stylesheet" href="../gitbook/style.css">
  11. <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
  12. <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
  13. <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
  14. <meta name="HandheldFriendly" content="true"/>
  15. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  16. <meta name="apple-mobile-web-app-capable" content="yes">
  17. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  18. <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
  19. <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
  20. <link rel="next" href="../qi-ta-bu-chong.html" />
  21. <link rel="prev" href="mo-xing.html" />
  22. </head>
  23. <body>
  24. <div class="book">
  25. <div class="book-summary">
  26. <div id="book-search-input" role="search">
  27. <input type="text" placeholder="Type to search" />
  28. </div>
  29. <nav role="navigation">
  30. <ul class="summary">
  31. <li class="chapter " data-level="1.1" data-path="../">
  32. <a href="../">
  33. 简介
  34. </a>
  35. </li>
  36. <li class="chapter " data-level="1.2" data-path="../chapter1.html">
  37. <a href="../chapter1.html">
  38. 基础用法
  39. </a>
  40. <ul class="articles">
  41. <li class="chapter " data-level="1.2.1" data-path="pei-zhi.html">
  42. <a href="pei-zhi.html">
  43. 配置
  44. </a>
  45. </li>
  46. <li class="chapter " data-level="1.2.2" data-path="lu-you.html">
  47. <a href="lu-you.html">
  48. 路由
  49. </a>
  50. </li>
  51. <li class="chapter " data-level="1.2.3" data-path="kong-zhi-qi.html">
  52. <a href="kong-zhi-qi.html">
  53. 控制器
  54. </a>
  55. </li>
  56. <li class="chapter " data-level="1.2.4" data-path="mo-xing.html">
  57. <a href="mo-xing.html">
  58. 模型
  59. </a>
  60. </li>
  61. <li class="chapter active" data-level="1.2.5" data-path="shi-tu.html">
  62. <a href="shi-tu.html">
  63. 视图
  64. </a>
  65. </li>
  66. </ul>
  67. </li>
  68. <li class="chapter " data-level="1.3" data-path="../qi-ta-bu-chong.html">
  69. <a href="../qi-ta-bu-chong.html">
  70. 其他补充
  71. </a>
  72. <ul class="articles">
  73. <li class="chapter " data-level="1.3.1" data-path="../qi-ta-bu-chong/param.html">
  74. <a href="../qi-ta-bu-chong/param.html">
  75. Param
  76. </a>
  77. </li>
  78. <li class="chapter " data-level="1.3.2" data-path="../qi-ta-bu-chong/tablehelper.html">
  79. <a href="../qi-ta-bu-chong/tablehelper.html">
  80. TableHelper
  81. </a>
  82. </li>
  83. <li class="chapter " data-level="1.3.3" data-path="../qi-ta-bu-chong/ke-zhi-xing-jiao-ben.html">
  84. <a href="../qi-ta-bu-chong/ke-zhi-xing-jiao-ben.html">
  85. 可执行脚本
  86. </a>
  87. </li>
  88. </ul>
  89. </li>
  90. <li class="divider"></li>
  91. <li>
  92. <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
  93. Published with GitBook
  94. </a>
  95. </li>
  96. </ul>
  97. </nav>
  98. </div>
  99. <div class="book-body">
  100. <div class="body-inner">
  101. <div class="book-header" role="navigation">
  102. <!-- Title -->
  103. <h1>
  104. <i class="fa fa-circle-o-notch fa-spin"></i>
  105. <a href=".." >视图</a>
  106. </h1>
  107. </div>
  108. <div class="page-wrapper" tabindex="-1" role="main">
  109. <div class="page-inner">
  110. <div id="book-search-results">
  111. <div class="search-noresults">
  112. <section class="normal markdown-section">
  113. <h3 id="&#x89C6;&#x56FE;">&#x89C6;&#x56FE;</h3>
  114. <h6 id="&#x547D;&#x540D;&#x7EA6;&#x5B9A;">&#x547D;&#x540D;&#x7EA6;&#x5B9A;</h6>
  115. <pre><code>view root/ //view&#x76EE;&#x5F55;
  116. &#x2514;&#x2500;&#x2500; controller // &#x63A7;&#x5236;&#x5668;&#x6587;&#x4EF6;&#x5939;
  117. &#x2514;&#x2500;&#x2500; action.html // &#x5BF9;&#x5E94;&#x65B9;&#x6CD5;&#x7684;&#x6A21;&#x677F;&#x6587;&#x4EF6;
  118. </code></pre><h6 id="&#x6A21;&#x677F;&#x4F7F;&#x7528;">&#x6A21;&#x677F;&#x4F7F;&#x7528;</h6>
  119. <p>&#x9700;&#x8981;&#x4F7F;&#x7528;&#x6A21;&#x677F;&#x6E32;&#x67D3;&#x7684;&#x63A7;&#x5236;&#x5668;&#x9700;&#x8981;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x7236;&#x7C7B;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x542F;&#x52A8;&#xFF08;&#x9ED8;&#x8BA4;&#x5173;&#x95ED;&#xFF09;&#xFF0C;&#x6846;&#x67B6;&#x4F7F;&#x7528;&#x7684;&#x662F;&#x539F;&#x751F;PHP&#x505A;&#x6A21;&#x677F;&#x5F15;&#x64CE;&#x3002;</p>
  120. <p>&#x5B9E;&#x4F8B;:</p>
  121. <pre><code class="lang-php"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">FooController</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">BaseController</span> </span>{
  122. <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">__construct</span><span class="hljs-params">()</span> </span>{
  123. <span class="hljs-keyword">parent</span>::__construct(<span class="hljs-keyword">true</span>); <span class="hljs-comment">// &#x5F00;&#x542F;&#x6A21;&#x677F;</span>
  124. }
  125. <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">actionBar</span><span class="hljs-params">($args)</span> </span>{
  126. $rules = [
  127. <span class="hljs-string">&apos;name&apos;</span> =&gt; [<span class="hljs-string">&apos;string&apos;</span>, <span class="hljs-string">&apos;desc&apos;</span> =&gt; <span class="hljs-string">&apos;&#x6635;&#x79F0;&apos;</span>],
  128. ];
  129. Param::checkParam2($rules, $args);
  130. $this-&gt;tpl-&gt;assign([<span class="hljs-string">&apos;nicknam&apos;</span> =&gt; $args[<span class="hljs-string">&apos;name&apos;</span>]); <span class="hljs-comment">// &#x6CE8;&#x518C;&#x53D8;&#x91CF;</span>
  131. $this-&gt;tpl-&gt;display(<span class="hljs-string">&apos;foo/bar&apos;</span>); <span class="hljs-comment">// &#x6E32;&#x67D3;&#x6A21;&#x677F;</span>
  132. }
  133. }
  134. </code></pre>
  135. <pre><code class="lang-html"><span class="hljs-comment">&lt;!-- view/foo/bar.html --&gt;</span>
  136. <span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
  137. <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
  138. <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="php"><span class="hljs-meta">&lt;?</span>=$nickname;<span class="hljs-meta">?&gt;</span></span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
  139. <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
  140. <span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
  141. </code></pre>
  142. <h6 id="&#x8F93;&#x51FA;json&#x6570;&#x636E;">&#x8F93;&#x51FA;JSON&#x6570;&#x636E;</h6>
  143. <p>&#x6846;&#x67B6;&#x4E3A;&#x63A5;&#x53E3;&#x65B9;&#x6CD5;&#x63D0;&#x4F9B;&#x4E86;<code>Response</code>&#x7EDF;&#x4E00;&#x6807;&#x51C6;&#x8F93;&#x51FA;&#xFF1B;&#x540C;&#x65F6;&#x5C01;&#x88C5;&#x4E86;log&#x4E0A;&#x62A5;&#xFF0C;debug&#x4FE1;&#x606F;&#x6253;&#x5370;&#xFF0C;CORS&#x8BBE;&#x7F6E;&#xFF1B;&#x5E76;&#x4E14;<code>Response</code>&#x64CD;&#x4F5C;&#x4F1A;&#x7ED3;&#x675F;&#x7A0B;&#x5E8F;&#x8FD0;&#x884C;&#xFF0C;&#x6CE8;&#x610F;&#x4F7F;&#x7528;&#x3002;</p>
  144. <p>&#x793A;&#x4F8B;:</p>
  145. <pre><code class="lang-php">$data = [<span class="hljs-string">&apos;id&apos;</span> =&gt; <span class="hljs-number">123</span>];
  146. Response::success($data);
  147. <span class="hljs-comment">// output:</span>
  148. <span class="hljs-comment">// {&quot;result&quot;:1,&quot;code&quot;:0,&quot;msg&quot;:&quot;&#x6210;&#x529F;&quot;,&quot;data&quot;:{&quot;id&quot;:123}}</span>
  149. Response::error(CODE_NORMAL_ERROR, <span class="hljs-string">&apos;&#x83B7;&#x53D6;&#x6570;&#x636E;&#x5931;&#x8D25;&apos;</span>);
  150. <span class="hljs-comment">// CODE_NORMAL_ERROR &#x5B9A;&#x4E49;&#x5728;&#x540D;&#x5B57;&#x670D;&#x52A1; code &#x7684;&#x9519;&#x8BEF;&#x7801;&#x5E38;&#x91CF;</span>
  151. <span class="hljs-comment">// output:</span>
  152. <span class="hljs-comment">// {&quot;result&quot;:0,&quot;code&quot;:-9,&quot;msg&quot;:&quot;&#x83B7;&#x53D6;&#x6570;&#x636E;&#x5931;&#x8D25;&quot;}</span>
  153. </code></pre>
  154. </section>
  155. </div>
  156. <div class="search-results">
  157. <div class="has-results">
  158. <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
  159. <ul class="search-results-list"></ul>
  160. </div>
  161. <div class="no-results">
  162. <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
  163. </div>
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. <a href="mo-xing.html" class="navigation navigation-prev " aria-label="Previous page: 模型">
  170. <i class="fa fa-angle-left"></i>
  171. </a>
  172. <a href="../qi-ta-bu-chong.html" class="navigation navigation-next " aria-label="Next page: 其他补充">
  173. <i class="fa fa-angle-right"></i>
  174. </a>
  175. </div>
  176. <script>
  177. var gitbook = gitbook || [];
  178. gitbook.push(function() {
  179. gitbook.page.hasChanged({"page":{"title":"视图","level":"1.2.5","depth":2,"next":{"title":"其他补充","level":"1.3","depth":1,"path":"qi-ta-bu-chong.md","ref":"qi-ta-bu-chong.md","articles":[{"title":"Param","level":"1.3.1","depth":2,"path":"qi-ta-bu-chong/param.md","ref":"qi-ta-bu-chong/param.md","articles":[]},{"title":"TableHelper","level":"1.3.2","depth":2,"path":"qi-ta-bu-chong/tablehelper.md","ref":"qi-ta-bu-chong/tablehelper.md","articles":[]},{"title":"可执行脚本","level":"1.3.3","depth":2,"path":"qi-ta-bu-chong/ke-zhi-xing-jiao-ben.md","ref":"qi-ta-bu-chong/ke-zhi-xing-jiao-ben.md","articles":[]}]},"previous":{"title":"模型","level":"1.2.4","depth":2,"path":"chapter1/mo-xing.md","ref":"chapter1/mo-xing.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"chapter1/shi-tu.md","mtime":"2018-09-08T08:20:23.151Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-09-13T03:13:15.790Z"},"basePath":"..","book":{"language":""}});
  180. });
  181. </script>
  182. </div>
  183. <script src="../gitbook/gitbook.js"></script>
  184. <script src="../gitbook/theme.js"></script>
  185. <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
  186. <script src="../gitbook/gitbook-plugin-search/search.js"></script>
  187. <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
  188. <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
  189. <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
  190. <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
  191. </body>
  192. </html>