├── .gitignore ├── LICENSE ├── README.md ├── SUMMARY.md ├── _book ├── LICENSE ├── gitbook │ ├── app.js │ ├── fonts │ │ └── fontawesome │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.svg │ │ │ ├── fontawesome-webfont.ttf │ │ │ └── fontawesome-webfont.woff │ ├── images │ │ ├── apple-touch-icon-precomposed-152.png │ │ └── favicon.ico │ ├── print.css │ └── style.css ├── index.html ├── search_index.json ├── 常见问题 │ ├── h5如何发布和部署.html │ ├── index.html │ └── 如何获取url上面的参数.html ├── 环境搭建 │ ├── index.html │ ├── 各种依赖.html │ ├── 线上调试.html │ └── 项目脚手架.html ├── 示例 │ └── index.html ├── 组件库 │ └── index.html ├── 编码标准 │ ├── index.html │ ├── 样式.html │ ├── 模板.html │ └── 脚本.html └── 语法介绍 │ ├── html模板.html │ ├── index.html │ ├── script脚本.html │ └── style样式.html ├── book.json ├── 常见问题 ├── README.md ├── h5如何发布和部署.md └── 如何获取url上面的参数.md ├── 环境搭建 ├── README.md ├── 各种依赖.md ├── 线上调试.md └── 项目脚手架.md ├── 示例 └── README.md ├── 组件库 └── README.md ├── 编码标准 ├── README.md ├── 样式.md ├── 模板.md └── 脚本.md └── 语法介绍 ├── README.md ├── html模板.md ├── script脚本.md └── style样式.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # h5weex-books 2 | 3 | > h5weex开发相关文章 4 | 5 | #### 主要内容: 6 | 7 | - 1、环境搭建 8 | - 2、语法介绍 9 | - 3、编码标准 10 | - 4、组件库 11 | - 5、示例 12 | - 6、常见问题 13 | -------------------------------------------------------------------------------- /SUMMARY.md: -------------------------------------------------------------------------------- 1 | Summary of my h5 weex book. 2 | 3 | * [环境搭建](环境搭建/README.md) 4 | * [各种依赖](环境搭建/各种依赖.md) 5 | * [项目脚手架](环境搭建/项目脚手架.md) 6 | * [线上调试](环境搭建/线上调试.md) 7 | * [语法介绍](语法介绍/README.md) 8 | * [html模板](语法介绍/html模板.md) 9 | * [style样式](语法介绍/style样式.md) 10 | * [script脚本](语法介绍/script脚本.md) 11 | * [编码标准](编码标准/README.md) 12 | * [模板](编码标准/模板.md) 13 | * [样式](编码标准/样式.md) 14 | * [脚本](编码标准/脚本.md) 15 | * [组件库](组件库/README.md) 16 | * [示例](示例/README.md) 17 | * [常见问题](常见问题/README.md) 18 | * [h5如何发布和部署](常见问题/h5如何发布和部署.md) 19 | * [如何获取url上面的参数](常见问题/如何获取url上面的参数.md) 20 | -------------------------------------------------------------------------------- /_book/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /_book/gitbook/fonts/fontawesome/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h5weex/h5weex-books/0f47ae18af25d64bb5ced70f44b0ba9ab4c3c262/_book/gitbook/fonts/fontawesome/FontAwesome.otf -------------------------------------------------------------------------------- /_book/gitbook/fonts/fontawesome/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h5weex/h5weex-books/0f47ae18af25d64bb5ced70f44b0ba9ab4c3c262/_book/gitbook/fonts/fontawesome/fontawesome-webfont.eot -------------------------------------------------------------------------------- /_book/gitbook/fonts/fontawesome/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h5weex/h5weex-books/0f47ae18af25d64bb5ced70f44b0ba9ab4c3c262/_book/gitbook/fonts/fontawesome/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /_book/gitbook/fonts/fontawesome/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h5weex/h5weex-books/0f47ae18af25d64bb5ced70f44b0ba9ab4c3c262/_book/gitbook/fonts/fontawesome/fontawesome-webfont.woff -------------------------------------------------------------------------------- /_book/gitbook/images/apple-touch-icon-precomposed-152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h5weex/h5weex-books/0f47ae18af25d64bb5ced70f44b0ba9ab4c3c262/_book/gitbook/images/apple-touch-icon-precomposed-152.png -------------------------------------------------------------------------------- /_book/gitbook/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h5weex/h5weex-books/0f47ae18af25d64bb5ced70f44b0ba9ab4c3c262/_book/gitbook/images/favicon.ico -------------------------------------------------------------------------------- /_book/gitbook/print.css: -------------------------------------------------------------------------------- 1 | .link-inherit{color:inherit}.link-inherit:hover,.link-inherit:focus{color:inherit}.hidden{display:none}.hljs-comment,.hljs-title{color:#8e908c}.hljs-variable,.hljs-attribute,.hljs-tag,.hljs-regexp,.ruby .hljs-constant,.xml .hljs-tag .hljs-title,.xml .hljs-pi,.xml .hljs-doctype,.html .hljs-doctype,.css .hljs-id,.css .hljs-class,.css .hljs-pseudo{color:#c82829}.hljs-number,.hljs-preprocessor,.hljs-pragma,.hljs-built_in,.hljs-literal,.hljs-params,.hljs-constant{color:#f5871f}.ruby .hljs-class .hljs-title,.css .hljs-rules .hljs-attribute{color:#eab700}.hljs-string,.hljs-value,.hljs-inheritance,.hljs-header,.ruby .hljs-symbol,.xml .hljs-cdata{color:#718c00}.css .hljs-hexcolor{color:#3e999f}.hljs-function,.python .hljs-decorator,.python .hljs-title,.ruby .hljs-function .hljs-title,.ruby .hljs-title .hljs-keyword,.perl .hljs-sub,.javascript .hljs-title,.coffeescript .hljs-title{color:#4271ae}.hljs-keyword,.javascript .hljs-function{color:#8959a8}.hljs{display:block;background:white;color:#4d4d4c;padding:.5em}.coffeescript .javascript,.javascript .xml,.tex .hljs-formula,.xml .javascript,.xml .vbscript,.xml .css,.xml .hljs-cdata{opacity:.5}.page.page-toc .glossary{margin-bottom:40px}.page.page-toc .glossary h2 a,.page.page-toc .glossary h2 a:hover{color:inherit;text-decoration:none}.page.page-toc .glossary .glossary-index{list-style:none;margin:0;padding:0}.page.page-toc .glossary .glossary-index li{display:inline;margin:0 8px;white-space:nowrap}.page .book-chapter{display:none}body .page{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;line-height:1.4;color:#333;overflow:hidden;line-height:1.6;word-wrap:break-word;display:block}body .page>*:first-child{margin-top:0!important}body .page>*:last-child{margin-bottom:0!important}body .page a{background:transparent}body .page a:active,body .page a:hover{outline:0}body .page strong{font-weight:bold}body .page h1{font-size:2em;margin:.67em 0}body .page img{border:0}body .page hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}body .page pre{overflow:auto}body .page code,body .page pre{font-family:monospace,monospace;font-size:1em;direction:ltr}body .page table{border-collapse:collapse;border-spacing:0}body .page td,body .page th{padding:0}body .page *{-moz-box-sizing:border-box;box-sizing:border-box}body .page a{color:#4183c4;text-decoration:none}body .page a:hover,body .page a:focus,body .page a:active{text-decoration:underline}body .page hr{height:0;margin:15px 0;overflow:hidden;background:transparent;border:0;border-bottom:1px solid #ddd}body .page hr:before,body .page hr:after{display:table;content:" "}body .page hr:after{clear:both}body .page h1,body .page h2,body .page h3,body .page h4,body .page h5,body .page h6{margin-top:15px;margin-bottom:15px;line-height:1.1}body .page h1{font-size:30px}body .page h2{font-size:21px}body .page h3{font-size:16px}body .page h4{font-size:14px}body .page h5{font-size:12px}body .page h6{font-size:11px}body .page blockquote{margin:0}body .page ul,body .page ol{padding:0;margin-top:0;margin-bottom:0}body .page ol ol{list-style-type:lower-roman}body .page dd{margin-left:0}body .page code,body .page pre{font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px}body .page pre{margin-top:0;margin-bottom:0}body .page .markdown-body>*:first-child{margin-top:0!important}body .page .markdown-body>*:last-child{margin-bottom:0!important}body .page .anchor{position:absolute;top:0;bottom:0;left:0;display:block;padding-right:6px;padding-left:30px;margin-left:-30px}body .page .anchor:focus{outline:0}body .page h1,body .page h2,body .page h3,body .page h4,body .page h5,body .page h6{position:relative;margin-top:1em;margin-bottom:16px;font-weight:bold;line-height:1.4}body .page h1{padding-bottom:.3em;font-size:2.25em;line-height:1.2;border-bottom:1px solid #eee}body .page h2{padding-bottom:.3em;font-size:1.75em;line-height:1.225;border-bottom:1px solid #eee}body .page h3{font-size:1.5em;line-height:1.43}body .page h4{font-size:1.25em}body .page h5{font-size:1em}body .page h6{font-size:1em;color:#777}body .page p,body .page blockquote,body .page ul,body .page ol,body .page dl,body .page table,body .page pre{margin-top:0;margin-bottom:16px}body .page hr{height:4px;padding:0;margin:16px 0;background-color:#e7e7e7;border:0 none}body .page ul,body .page ol{padding-left:2em}body .page ol ol,body .page ol ul,body .page ul ul{margin-top:0;margin-bottom:0}body .page dl{padding:0}body .page dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:bold}body .page dl dd{padding:0 16px;margin-bottom:16px}body .page blockquote{padding:0 15px;color:#777;border-left:4px solid #ddd}body .page blockquote>:first-child{margin-top:0}body .page blockquote>:last-child{margin-bottom:0}body .page table{display:block;width:100%;overflow:auto}body .page table th{font-weight:bold}body .page table th,body .page table td{padding:6px 13px;border:1px solid #ddd}body .page table tr{background-color:#fff;border-top:1px solid #ccc}body .page table tr:nth-child(2n){background-color:#f8f8f8}body .page img{max-width:100%;-moz-box-sizing:border-box;box-sizing:border-box;page-break-inside:avoid}body .page code{padding:0;padding-top:.2em;padding-bottom:.2em;margin:0;font-size:85%;background-color:#f7f7f7;border-radius:3px}body .page code:before,body .page code:after{letter-spacing:-0.2em;content:"\00a0"}body .page pre>code{padding:0;margin:0;font-size:100%;white-space:pre;background:transparent;border:0}body .page .highlight pre,body .page pre{padding:16px;overflow:auto;font-size:85%;line-height:1.45;background-color:#f7f7f7;border:0;border-radius:3px}body .page pre{word-wrap:normal}body .page pre code{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}body .page pre code:before,body .page pre code:after{content:normal}body .page .highlight{background:#fff} -------------------------------------------------------------------------------- /_book/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Introduction | h5weex-books 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
38 | 39 | 40 |
41 | 44 | 350 |
351 | 352 |
353 |
354 |
355 | 356 | 357 | 358 | 359 | 386 | 387 | 388 | 389 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 |

433 | 434 | h5weex-books 435 |

436 |
437 | 438 |
439 |
440 | 441 | 442 |
443 | 444 |

h5weex-books

445 |
446 |

h5weex开发相关文章

447 |
448 |

主要内容:

449 |
    450 |
  • 1、环境搭建
  • 451 |
  • 2、语法介绍
  • 452 |
  • 3、编码标准
  • 453 |
  • 4、组件库
  • 454 |
  • 5、示例
  • 455 |
  • 6、常见问题
  • 456 |
457 | 458 | 459 |
460 | 461 | 462 |
463 |
464 |
465 | 466 | 467 | 468 | 469 | 470 |
471 |
472 | 473 | 474 | 475 | 476 | 482 | 483 | 484 | 485 | 486 | 487 | -------------------------------------------------------------------------------- /_book/常见问题/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 常见问题 | h5weex-books 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 | 42 |
43 | 46 | 352 |
353 | 354 |
355 |
356 |
357 | 358 | 359 | 360 | 361 | 388 | 389 | 390 | 391 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 |

435 | 436 | h5weex-books 437 |

438 |
439 | 440 |
441 |
442 | 443 | 444 |
445 | 446 |

section 6

447 | 448 | 449 |
450 | 451 | 452 |
453 |
454 |
455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 |
463 |
464 | 465 | 466 | 467 | 468 | 474 | 475 | 476 | 477 | 478 | 479 | -------------------------------------------------------------------------------- /_book/常见问题/如何获取url上面的参数.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 如何获取url上面的参数 | h5weex-books 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
38 | 39 | 40 |
41 | 44 | 350 |
351 | 352 |
353 |
354 |
355 | 356 | 357 | 358 | 359 | 386 | 387 | 388 | 389 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 |

433 | 434 | h5weex-books 435 |

436 |
437 | 438 |
439 |
440 | 441 | 442 |
443 | 444 |

如何获取url上面的参数

445 |
    446 |
  • 在.we文件中是没有window等对象,意味着无法通过window.location来获取URL参数的值;
  • 447 |
  • 好在weex中提供了一个获取配置的方法:this.$getConfig(),通过该方法是可以获取URL上的参数,代码如下:
  • 448 |
449 |
/**
450 |  * 获取URL参数
451 |  */
452 | getUrlParam: function (key) {
453 |     var t = this.$getConfig().bundleUrl;
454 |     var reg = new RegExp('[?|&]' + key + '=([^&]+)');
455 |     var match = t.match(reg);
456 |     return match && match[1];
457 | }
458 | 
459 | 460 |
461 | 462 | 463 |
464 |
465 |
466 | 467 | 468 | 469 | 470 | 471 |
472 |
473 | 474 | 475 | 476 | 477 | 483 | 484 | 485 | 486 | 487 | 488 | -------------------------------------------------------------------------------- /_book/环境搭建/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 环境搭建 | h5weex-books 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 | 42 |
43 | 46 | 352 |
353 | 354 |
355 |
356 |
357 | 358 | 359 | 360 | 361 | 388 | 389 | 390 | 391 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 |

435 | 436 | h5weex-books 437 |

438 |
439 | 440 |
441 |
442 | 443 | 444 |
445 | 446 |

环境搭建

447 |
    448 |
  • 各种依赖
  • 449 |
  • 项目脚手架
  • 450 |
  • 线上调试
  • 451 |
452 | 453 | 454 |
455 | 456 | 457 |
458 |
459 |
460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 |
468 |
469 | 470 | 471 | 472 | 473 | 479 | 480 | 481 | 482 | 483 | 484 | -------------------------------------------------------------------------------- /_book/环境搭建/线上调试.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 线上调试 | h5weex-books 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 | 42 |
43 | 46 | 352 |
353 | 354 |
355 |
356 |
357 | 358 | 359 | 360 | 361 | 388 | 389 | 390 | 391 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 |

435 | 436 | h5weex-books 437 |

438 |
439 | 440 |
441 |
442 | 443 | 444 |
445 | 446 |

线上调试

447 |

先讲下本地如何调试:

448 |
    449 |
  • weex代码本地调试可以借组chrome的开发者工具即可完成调试;
  • 450 |
  • 下载weex IDE,安装之后可以把代码贴进去,然后按ctrl+alt+t,也可进入调试;
  • 451 |
452 |

线上调试有点麻烦,需要你的APP支持weex才行,下面以手淘举例:

453 |
    454 |
  • 本地安装weex-toolkit,并且保证更新到最新版:npm install -g weex-toolkit
  • 455 |
  • 随便找个目录执行: weex debug
  • 456 |
  • 会自动打开一个网页,然后用手淘扫一下左下角的二维码;
  • 457 |
  • 点击页面左边的debugger按钮,会弹出类似chrome devtool
  • 458 |
  • 手淘再扫一下你刚刚那个线上的url的二维码,就可以在刚刚出来的浏览器的devtool调试了;
  • 459 |
460 | 461 | 462 |
463 | 464 | 465 |
466 |
467 |
468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 |
476 |
477 | 478 | 479 | 480 | 481 | 487 | 488 | 489 | 490 | 491 | 492 | -------------------------------------------------------------------------------- /_book/示例/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 示例 | h5weex-books 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 | 42 |
43 | 46 | 352 |
353 | 354 |
355 |
356 |
357 | 358 | 359 | 360 | 361 | 388 | 389 | 390 | 391 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 |

435 | 436 | h5weex-books 437 |

438 |
439 | 440 |
441 |
442 | 443 | 444 |
445 | 446 |

示例

447 |

所有的示例会在这里定义,请访问:https://github.com/h5weex/h5weex-example

448 | 449 | 450 |
451 | 452 | 453 |
454 |
455 |
456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 |
464 |
465 | 466 | 467 | 468 | 469 | 475 | 476 | 477 | 478 | 479 | 480 | -------------------------------------------------------------------------------- /_book/组件库/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 组件库 | h5weex-books 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 | 42 |
43 | 46 | 352 |
353 | 354 |
355 |
356 |
357 | 358 | 359 | 360 | 361 | 388 | 389 | 390 | 391 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 |

435 | 436 | h5weex-books 437 |

438 |
439 | 440 |
441 |
442 | 443 | 444 |
445 | 446 |

组件库

447 |

所有的组件会在这里定义,请访问:https://github.com/h5weex/h5weex-components

448 | 449 | 450 |
451 | 452 | 453 |
454 |
455 |
456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 |
464 |
465 | 466 | 467 | 468 | 469 | 475 | 476 | 477 | 478 | 479 | 480 | -------------------------------------------------------------------------------- /_book/编码标准/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 编码标准 | h5weex-books 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 | 42 |
43 | 46 | 352 |
353 | 354 |
355 |
356 |
357 | 358 | 359 | 360 | 361 | 388 | 389 | 390 | 391 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 |

435 | 436 | h5weex-books 437 |

438 |
439 | 440 |
441 |
442 | 443 | 444 |
445 | 446 |

编码标准

447 |
    448 |
  • 模板
  • 449 |
  • 样式
  • 450 |
  • 脚本
  • 451 |
452 | 453 | 454 |
455 | 456 | 457 |
458 |
459 |
460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 |
468 |
469 | 470 | 471 | 472 | 473 | 479 | 480 | 481 | 482 | 483 | 484 | -------------------------------------------------------------------------------- /_book/编码标准/模板.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 模板 | h5weex-books 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 | 42 |
43 | 46 | 352 |
353 | 354 |
355 |
356 |
357 | 358 | 359 | 360 | 361 | 388 | 389 | 390 | 391 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 |

435 | 436 | h5weex-books 437 |

438 |
439 | 440 |
441 |
442 | 443 | 444 |
445 | 446 |

模板

447 |

先看一个标准的模板代码:

448 |
<template>
449 |     <div data-role="recommend_itemlist">
450 |         <div class="wrapper" if="{{mds.itemList.length}}">
451 |             <div repeat="{{mds.itemList}}" url="{{url}}" class="item-url" onclick="goTargetUrl">
452 |                 <image src="{{pic_url}}" class="item-img"></image>
453 |                 <div class="item-info">
454 |                     <div class="item-price">
455 |                         <text class="item-price-text">¥</text>
456 |                         <text class="item-price-text big">{{price.split('.')[0]}}</text>
457 |                         <text class="item-price-text">{{price.split('.').length > 1 ? '.' + price.split('.')[1] : ''}}</text>
458 |                     </div>
459 |                 </div>
460 |             </div>
461 |         </div>
462 |     </div>
463 | </template>
464 | 
    465 |
  • 代码缩进建议在每个项目下搞个.editorconfig文件,自己根据喜好定义缩进是2个空格还是4个空格
  • 466 |
  • 标签上统一采用class来定义样式,避免classstyle混用的情况;
  • 467 |
  • class名采用短线来连接,不是驼峰式和下划线连接;
  • 468 |
469 | 470 | 471 |
472 | 473 | 474 |
475 |
476 |
477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 |
485 |
486 | 487 | 488 | 489 | 490 | 496 | 497 | 498 | 499 | 500 | 501 | -------------------------------------------------------------------------------- /_book/编码标准/脚本.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 脚本 | h5weex-books 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 | 42 |
43 | 46 | 352 |
353 | 354 |
355 |
356 |
357 | 358 | 359 | 360 | 361 | 388 | 389 | 390 | 391 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 |

435 | 436 | h5weex-books 437 |

438 |
439 | 440 |
441 |
442 | 443 | 444 |
445 | 446 |

脚本

447 |

先看一个标准的脚本定义代码:

448 |
<script>
449 |     module.exports = {
450 |         data: {
451 |             mds: {
452 |                 dataParams: {
453 |                     "catId": "-1"
454 |                 }
455 |             },
456 |             gdc: {
457 |                 "ownerId": 2202220535
458 |             }
459 |         },
460 |         methods: {
461 |             goTargetUrl: function(e) {
462 |                 require('@weex-module/event').openURL(e.target.attr.url);
463 |             },
464 | 
465 |             render: function(ds, gd){
466 |                 var vm = this;
467 |                 if(ds){ vm.mds = ds; }
468 |                 if(gd){ vm.gdc = gd; }
469 |             }
470 |         },
471 |         created: function () {
472 |             console.log('page created');
473 |         },
474 |         ready: function () {
475 |             console.log('page ready');
476 |         }
477 |     };
478 | </script>
479 | 
    480 |
  • 定义一个render方法,保证可以传数据,实现懒加载;
  • 481 |
  • created方法中用来定义动态数据的获取;
  • 482 |
  • reday方法常用来上报,不要在这里面获取数据,会导致页面重新渲染,消耗性能;
  • 483 |
484 | 485 | 486 |
487 | 488 | 489 |
490 |
491 |
492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 |
500 |
501 | 502 | 503 | 504 | 505 | 511 | 512 | 513 | 514 | 515 | 516 | -------------------------------------------------------------------------------- /_book/语法介绍/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 语法介绍 | h5weex-books 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 | 42 |
43 | 46 | 352 |
353 | 354 |
355 |
356 |
357 | 358 | 359 | 360 | 361 | 388 | 389 | 390 | 391 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 |

435 | 436 | h5weex-books 437 |

438 |
439 | 440 |
441 |
442 | 443 | 444 |
445 | 446 |

语法介绍

447 |

标准的weex程序包含三个部分,如下:

448 |
<template>
449 |   <!-- (required) the structure of page -->
450 | </template>
451 | 
452 | <style>
453 |   /* (optional) stylesheet */
454 | </style>
455 | 
456 | <script>
457 |   /* (optional) the definition of data, methods and life-circle */
458 | </script>
459 | 
    460 |
  • template
  • 461 |
  • style
  • 462 |
  • script
  • 463 |
464 | 465 | 466 |
467 | 468 | 469 |
470 |
471 |
472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 |
480 |
481 | 482 | 483 | 484 | 485 | 491 | 492 | 493 | 494 | 495 | 496 | -------------------------------------------------------------------------------- /_book/语法介绍/script脚本.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | script脚本 | h5weex-books 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 | 42 |
43 | 46 | 352 |
353 | 354 |
355 |
356 |
357 | 358 | 359 | 360 | 361 | 388 | 389 | 390 | 391 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 |

435 | 436 | h5weex-books 437 |

438 |
439 | 440 |
441 |
442 | 443 | 444 |
445 | 446 |

script脚本

447 |

先看一个hello world的实现:

448 |
<template>
449 |     <container>
450 |         <text>{{myname}}</text>
451 |     </container>
452 | </template>
453 | 
454 | <script>
455 | module.exports = {
456 |     data: {
457 |         "myname": "hello world"
458 |     },
459 |     methods: {
460 |         render: function(ds) {
461 |             this.myname = ds;
462 |         }
463 |     },
464 |     created: function () {
465 | 
466 |     },
467 |     ready: function () {
468 | 
469 |     }
470 | };
471 | </script>
472 | 
    473 |
  • 必须是以<script>标签来包含你的脚本;
  • 474 |
  • 必须把脚本都定义在module.exports这个对象中;
  • 475 |
  • data里面是定义的数据对象,可以通过this.xxx获取,在模板中是通过``来获取;
  • 476 |
  • methods对象中用来定义自己的函数;
  • 477 |
  • created是生命周期函数,这个时候模板还没有被渲染,常用来在这里定义数据的更新和获取;
  • 478 |
  • ready是生命周期函数,这个时候模板被渲染,常用来做一些自己上报等;
  • 479 |
480 | 481 | 482 |
483 | 484 | 485 |
486 |
487 |
488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 |
496 |
497 | 498 | 499 | 500 | 501 | 507 | 508 | 509 | 510 | 511 | 512 | -------------------------------------------------------------------------------- /book.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "h5weex-books", 3 | "links": { 4 | "gitbook": false, 5 | "sharing": { 6 | "google": true, 7 | "facebook": true, 8 | "twitter": true, 9 | "all": true 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /常见问题/README.md: -------------------------------------------------------------------------------- 1 | # section 6 2 | -------------------------------------------------------------------------------- /常见问题/h5如何发布和部署.md: -------------------------------------------------------------------------------- 1 | # h5如何发布和部署 2 | 3 | - 每个页面有一个模板文件,代码如下: 4 | 5 | ``` 6 | 7 | 8 | 9 | 10 | 示例 11 | 12 | 13 | 14 | 15 | 16 |
17 | 36 | 37 | 38 | ``` 39 | 40 | - 只需将模板文件发送到服务器端即可; 41 | 42 | - 每个.we的页面build后的bundle.js可以通过在这个url上的参数传入,这样改we代码可以单独发布CDN; 43 | 44 | - 如果想做离线化,可以把h5的weex库和bundle.js一起缓存到manifest中; 45 | -------------------------------------------------------------------------------- /常见问题/如何获取url上面的参数.md: -------------------------------------------------------------------------------- 1 | # 如何获取url上面的参数 2 | 3 | - 在.we文件中是没有window等对象,意味着无法通过window.location来获取URL参数的值; 4 | - 好在weex中提供了一个获取配置的方法:`this.$getConfig()`,通过该方法是可以获取URL上的参数,代码如下: 5 | 6 | ``` 7 | /** 8 | * 获取URL参数 9 | */ 10 | getUrlParam: function (key) { 11 | var t = this.$getConfig().bundleUrl; 12 | var reg = new RegExp('[?|&]' + key + '=([^&]+)'); 13 | var match = t.match(reg); 14 | return match && match[1]; 15 | } 16 | ``` 17 | -------------------------------------------------------------------------------- /环境搭建/README.md: -------------------------------------------------------------------------------- 1 | # 环境搭建 2 | 3 | - 各种依赖 4 | - 项目脚手架 5 | - 线上调试 6 | -------------------------------------------------------------------------------- /环境搭建/各种依赖.md: -------------------------------------------------------------------------------- 1 | # 各种依赖 2 | 3 | 以h5方式运行weex其实就一个浏览器就够了,但是开发weex页面就需要很多依赖了,推荐是mac机器下开发,各种命令行着实很方便。 4 | 5 | - node.js 6 | 7 | 下载地址:http://nodejs.cn/ , 下载回来双击进入安装,不需要修改安装目录,安装完成后就有npm这个命令了; 8 | 9 | - cnpm 10 | 11 | 为了更快的下载npm包,建议安装一个cnpm,这样在国内的速度是杠杠滴呀 12 | 13 | ``` 14 | npm install -g cnpm --registry=https://registry.npm.taobao.org 15 | ``` 16 | 17 | - webpack 18 | 19 | 当下最流行的打包工具,用来打包we文件成一个可执行的bundle.js 20 | 21 | ``` 22 | sudo cnpm install -g webpack 23 | ``` 24 | 25 | - gulp 26 | 27 | 因为在一个项目中开发中,需要多个命令和任务处理,这里我们选择了gulp 28 | 29 | ``` 30 | sudo cnpm install -g gulp 31 | ``` 32 | 33 | 通过以上命令,安装了各种依赖之后,安装前面提到的开发脚手架,开始开发你的weex程序吧! 34 | 35 | 36 | 欢迎推荐你身边的前端同学一起来关注我们,关注h5weex。 37 | 38 | ![](https://img.alicdn.com/tps/TB1C36iNpXXXXaLXVXXXXXXXXXX-430-430.jpg_200x200) 39 | -------------------------------------------------------------------------------- /环境搭建/线上调试.md: -------------------------------------------------------------------------------- 1 | # 线上调试 2 | 3 | 先讲下本地如何调试: 4 | 5 | - weex代码本地调试可以借组chrome的开发者工具即可完成调试; 6 | - 下载weex IDE,安装之后可以把代码贴进去,然后按`ctrl+alt+t`,也可进入调试; 7 | 8 | 线上调试有点麻烦,需要你的APP支持weex才行,下面以`手淘`举例: 9 | 10 | - 本地安装`weex-toolkit`,并且保证更新到最新版:`npm install -g weex-toolkit`; 11 | - 随便找个目录执行: `weex debug`; 12 | - 会自动打开一个网页,然后用手淘扫一下左下角的二维码; 13 | - 点击页面左边的debugger按钮,会弹出类似`chrome devtool`; 14 | - 手淘再扫一下你刚刚那个线上的url的二维码,就可以在刚刚出来的浏览器的devtool调试了; 15 | -------------------------------------------------------------------------------- /环境搭建/项目脚手架.md: -------------------------------------------------------------------------------- 1 | # 项目脚手架 2 | 3 | - 安装yo神器 (用来执行脚手架的工具) 4 | 5 | ``` 6 | sudo npm install -g yo 7 | ``` 8 | 9 | - 安装项目脚手架 10 | 11 | ``` 12 | npm install -g generator-h5weex 13 | ``` 14 | 15 | - 在你的电脑上任意位置,新建一个目录,如:testapp 16 | 17 | ``` 18 | cd /home 19 | mkdir testapp 20 | ``` 21 | 22 | - 进入目录,执行初始化项目 23 | 24 | ``` 25 | yo h5weex 26 | ``` 27 | 28 | 然后一个空的项目就建立起来了,你将看到这样的目录结构: 29 | ``` 30 | |- testapp/ #项目目录 31 | |- src/ 32 | |- p #页面 33 | |- c #组件 34 | |- build #打包后的bundle文件 35 | |- node_modules 36 | |- index.html #访问入口文件 37 | |- webpack.config.js #打包weex代码的脚本 38 | |- .editorconfig 39 | |- .gitignore 40 | |- .npmrc 41 | |- changelog.md 42 | |- gulpfile.js 43 | |- package.json 44 | |- README.md 45 | ``` 46 | 47 | 先别捉急着去运行哈,因为还没有任何可运行的页面,所以我们先为项目创建一个页面: 48 | 49 | ``` 50 | yo h5weex:p index 51 | ``` 52 | 53 | 这样我们创建了一个index的页面,先把页面源码打包成一个可执行的weex文件: 54 | 55 | ``` 56 | gulp build 57 | ``` 58 | 59 | 尼玛,憋了那么久了,怎么还不能看运行效果呢,下面就可以看效果了: 60 | 61 | ``` 62 | gulp 63 | ``` 64 | 65 | 这个神奇的命令一旦执行完,浏览器就自动打开了,你也将看到这个脚手架里面默认给你写的一个weex程序了。如下图: 66 | 67 | ![](https://img.alicdn.com/tps/TB1eg.yLXXXXXXMaXXXXXXXXXXX-1536-2700.jpg_640x640) 68 | 69 | 好了,相信你有兴趣去改这个默认源码的冲动了,那就在自己的电脑上,按照上面的说明开始你的weex之路吧。 70 | 71 | 点击这里查看脚手架源码:[https://github.com/h5weex/generator-h5weex](https://github.com/h5weex/generator-h5weex) 72 | 73 | 欢迎推荐你身边的前端同学一起来关注我们,关注h5weex。 74 | 75 | ![](https://img.alicdn.com/tps/TB1C36iNpXXXXaLXVXXXXXXXXXX-430-430.jpg_200x200) 76 | -------------------------------------------------------------------------------- /示例/README.md: -------------------------------------------------------------------------------- 1 | # 示例 2 | 3 | 所有的示例会在这里定义,请访问:https://github.com/h5weex/h5weex-example 4 | -------------------------------------------------------------------------------- /组件库/README.md: -------------------------------------------------------------------------------- 1 | # 组件库 2 | 3 | 所有的组件会在这里定义,请访问:https://github.com/h5weex/h5weex-components 4 | -------------------------------------------------------------------------------- /编码标准/README.md: -------------------------------------------------------------------------------- 1 | # 编码标准 2 | 3 | - 模板 4 | - 样式 5 | - 脚本 6 | -------------------------------------------------------------------------------- /编码标准/样式.md: -------------------------------------------------------------------------------- 1 | # 样式 2 | 3 | 先看一个标准的style定义代码: 4 | 5 | ``` 6 | 61 | ``` 62 | 63 | - weex内置了响应式的支持,页面的宽度是以`750`来做为标准,自动适配所有手机; 64 | - 所有的宽度和高度的定义不需要带单位,如px,rem等,仅仅写数字即可; 65 | - 一个容器的高度可以不定义,但是``必须定义width和height; 66 | -------------------------------------------------------------------------------- /编码标准/模板.md: -------------------------------------------------------------------------------- 1 | # 模板 2 | 3 | 先看一个标准的模板代码: 4 | 5 | ``` 6 | 22 | ``` 23 | 24 | - 代码缩进建议在每个项目下搞个`.editorconfig`文件,自己根据喜好定义缩进是2个空格还是4个空格 25 | - 标签上统一采用`class`来定义样式,避免`class`和`style`混用的情况; 26 | - `class`名采用短线来连接,不是驼峰式和下划线连接; 27 | -------------------------------------------------------------------------------- /编码标准/脚本.md: -------------------------------------------------------------------------------- 1 | # 脚本 2 | 3 | 先看一个标准的脚本定义代码: 4 | 5 | ``` 6 | 37 | ``` 38 | 39 | - 定义一个`render`方法,保证可以传数据,实现懒加载; 40 | - `created`方法中用来定义动态数据的获取; 41 | - `reday`方法常用来上报,不要在这里面获取数据,会导致页面重新渲染,消耗性能; 42 | -------------------------------------------------------------------------------- /语法介绍/README.md: -------------------------------------------------------------------------------- 1 | # 语法介绍 2 | 3 | 标准的weex程序包含三个部分,如下: 4 | 5 | ``` 6 | 9 | 10 | 13 | 14 | 17 | ``` 18 | 19 | - template 20 | - style 21 | - script 22 | -------------------------------------------------------------------------------- /语法介绍/html模板.md: -------------------------------------------------------------------------------- 1 | # html模板 2 | 3 | 先看一个`hello world`的模板: 4 | 5 | ``` 6 | 11 | ``` 12 | 13 | - 必须是以`