http://git-wip-us.apache.org/repos/asf/incubator-weex-site/blob/f3d58bd0/cn/v-0.10/advanced/create-a-weex-project.html ---------------------------------------------------------------------- diff --git a/cn/v-0.10/advanced/create-a-weex-project.html b/cn/v-0.10/advanced/create-a-weex-project.html deleted file mode 100644 index 69216b8..0000000 --- a/cn/v-0.10/advanced/create-a-weex-project.html +++ /dev/null @@ -1,506 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <meta charset="utf-8"> - - <title>å¦ä½å建ä¸ä¸ª Weex é¡¹ç® | Weex</title> - <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> - <meta name="description" content="å¦ä½å建ä¸ä¸ª Weex 项ç®å¯¹äºå端å¼åè æ¥è¯´å¼åä¸ä¸ª app æ¯ä¸å®¹æçï¼æ¢ç¶ Weex è½ä»¥ web çå¼åä½éªæ建é«æ§è½ãå¯æ©å±ç native åºç¨ï¼é£æ们æä¹å©ç¨ Weex ç®åé«æçå¼åä¸ä¸ª native åºç¨å¢ï¼Weex æ¿ä½ èèäºè¿ä»¶äºãå¨æ¬ç« ä¸ï¼æ们å°å¦ä¹ å¦ä½ä½¿ç¨ Weexpack å·¥å ·å¿«éçæä¸ä¸ªå ¨æ°ç Weex 项ç®ã æ ¹æ®ä½ çæä½ç³»ç»çä¸åï¼æ¥éª¤ä¹ç¥æå·®å¼ï¼å¦æä½ ä»æªæ¥è§¦è¿"> -<meta property="og:type" content="website"> -<meta property="og:title" content="å¦ä½å建ä¸ä¸ª Weex 项ç®"> -<meta property="og:url" content="https://weex-project.io/cn/v-0.10/advanced/create-a-weex-project.html"> -<meta property="og:site_name" content="Weex"> -<meta property="og:description" content="å¦ä½å建ä¸ä¸ª Weex 项ç®å¯¹äºå端å¼åè æ¥è¯´å¼åä¸ä¸ª app æ¯ä¸å®¹æçï¼æ¢ç¶ Weex è½ä»¥ web çå¼åä½éªæ建é«æ§è½ãå¯æ©å±ç native åºç¨ï¼é£æ们æä¹å©ç¨ Weex ç®åé«æçå¼åä¸ä¸ª native åºç¨å¢ï¼Weex æ¿ä½ èèäºè¿ä»¶äºãå¨æ¬ç« ä¸ï¼æ们å°å¦ä¹ å¦ä½ä½¿ç¨ Weexpack å·¥å ·å¿«éçæä¸ä¸ªå ¨æ°ç Weex 项ç®ã æ ¹æ®ä½ çæä½ç³»ç»çä¸åï¼æ¥éª¤ä¹ç¥æå·®å¼ï¼å¦æä½ ä»æªæ¥è§¦è¿"> -<meta property="og:image" content="https://img.alicdn.com/tps/TB1jLx4OFXXXXaoXFXXXXXXXXXX-212-33.png"> -<meta property="og:image" content="https://gw.alicdn.com/tps/TB1VulhOFXXXXcPXFXXXXXXXXXX-828-686.png"> -<meta property="og:image" content="https://img.alicdn.com/tps/TB1CBdgOFXXXXXnXVXXXXXXXXXX-661-392.jpg"> -<meta property="og:updated_time" content="2017-04-28T02:36:21.000Z"> -<meta name="twitter:card" content="summary"> -<meta name="twitter:title" content="å¦ä½å建ä¸ä¸ª Weex 项ç®"> -<meta name="twitter:description" content="å¦ä½å建ä¸ä¸ª Weex 项ç®å¯¹äºå端å¼åè æ¥è¯´å¼åä¸ä¸ª app æ¯ä¸å®¹æçï¼æ¢ç¶ Weex è½ä»¥ web çå¼åä½éªæ建é«æ§è½ãå¯æ©å±ç native åºç¨ï¼é£æ们æä¹å©ç¨ Weex ç®åé«æçå¼åä¸ä¸ª native åºç¨å¢ï¼Weex æ¿ä½ èèäºè¿ä»¶äºãå¨æ¬ç« ä¸ï¼æ们å°å¦ä¹ å¦ä½ä½¿ç¨ Weexpack å·¥å ·å¿«éçæä¸ä¸ªå ¨æ°ç Weex 项ç®ã æ ¹æ®ä½ çæä½ç³»ç»çä¸åï¼æ¥éª¤ä¹ç¥æå·®å¼ï¼å¦æä½ ä»æªæ¥è§¦è¿"> -<meta name="twitter:image" content="https://img.alicdn.com/tps/TB1jLx4OFXXXXaoXFXXXXXXXXXX-212-33.png"> - - <link rel="alternate" href="/atom.xml" title="Weex" type="application/atom+xml"> - - - <link rel="icon" href="//gw.alicdn.com/tps/TB1XNqxPXXXXXcSXVXXXXXXXXXX-64-63.png"> - - - <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css"> - - <link rel="stylesheet" href="/css/style.css"> - <link rel="stylesheet" href="/css/swiper.min.css"> -</head> - -<body id="advanced" class="lang-cn"> - - <script> - window.PAGE_TYPE = "advanced"; - window.ROOT = "/" - </script> - <header id="header"> - <div class="navbar"> - <a id="logo" href="/cn/"> - <img src="//img.alicdn.com/tps/TB1zBLaPXXXXXXeXXXXXXXXXXXX-121-59.svg" /> - </a> - <div class="main-nav"> - <ul class="links"> - <li><a href="/cn/guide">æç¨</a></li> - <li><a href="/cn/references">æå</a></li> - <li class="dropdown"> - <a href="javascript:;">åè</a> - <ul class="dropdown-menu subnav"> - <li> - <a href="/cn/faq.html">FAQ</a> - </li> - <li> - <a href="/cn/releasenote.html">çæ¬è¯´æ</a> - </li> - </ul> - </li> - <li class="dropdown"> - <a href="javascript:;">å·¥å ·åæå¡</a> - <ul class="dropdown-menu subnav"> - <li> - <a href="/cn/playground.html">Playground</a> - </li> - <li> - <a href="/cn/guide/tools/toolkit.html">Weex-toolkit</a> - </li> - <li> - <a href="http://dotwe.org" target="_blank">Code Snippets</a> - </li> - <li> - <a href="https://market.dotwe.org" target="_blank">Market</a> - </li> - </ul> - </li> - </ul> - <ul class="info"> - <li><a href="https://github.com/apache/incubator-weex/" target="_blank"><span class="btn-github iconfont icon-github"></span></a></li> - </ul> - <ul class="tools"> - <li> - <div class="search"> - <form id="search-form" class="search-form"> <!-- æç´¢æ¡ç¸å ³ --> - <input type="text" id="search-input-header" name="q" results="0" class="form-control search-input" autocomplete="off" autocorrect="off"/> - <span class="iconfont icon-search"></span> - </form> - <div class="results-panel"> - </div> -</div> - </li> - <li> - <div class="dropdown select-lang"> - <a href="javascript:;" class="dropdown-toggle"> - Language - <span class="caret"></span> - </a> - <ul class="dropdown-menu pick-lang"> - <li> - <a href="/v-0.10/advanced/create-a-weex-project.html" data-lang="en">English</a> - </li> - <li> - <a href="/cn/v-0.10/advanced/create-a-weex-project.html" data-lang="zh-cn">ä¸æ</a> - </li> - </ul> - </div> - </li> - <!--<li></li>--> - </ul> - </div> - </div> - <div id="mobile-nav"> - <a id="logo" href="/cn/"> - <img src="//img.alicdn.com/tps/TB1zBLaPXXXXXXeXXXXXXXXXXXX-121-59.svg" /> - </a> - <a class="btn-menu"><span class="iconfont icon-nav"></span></a> - </div> -</header> - - <div id="sidebar" class=""> - <div class="sidebar-menu"> - - <ul class="main-nav"> - <li> - <div class="search"> - <form id="search-form" class="search-form"> <!-- æç´¢æ¡ç¸å ³ --> - <input type="text" id="search-input-sidebar" name="q" results="0" class="form-control search-input" autocomplete="off" autocorrect="off"/> - <span class="iconfont icon-search"></span> - </form> - <div class="results-panel"> - </div> -</div> - </li> - <li> - <a class="" href="/cn/guide"> - æç¨ - </a> - </li> - <li> - <a class="" href="/cn/references"> - æå - </a> - </li> - <li> - <a href="/cn/faq.html"> - FAQ - </a> - </li> - <li> - <p>å·¥å ·åæå¡</p> - <ul class="subnav"> - <li> - <a href="/cn/playground.html">Playground</a> - </li> - <li> - <a href="/cn/guide/tools/devtools.html">Devtools</a> - </li> - <li> - <a href="/cn/guide/tools/weexpack.html">Weexpack</a> - </li> - <li> - <a href="http://dotwe.org" target="_blank">Snippets</a> - </li> - <li> - <a href="https://market.dotwe.org" target="_blank">Market</a> - </li> - </ul> - </li> - <li> - <a href="https://github.com/apache/incubator-weex/" target="_blank"> - GitHub - </a> - </li> - </ul> - - <a class="btn-close-sidebar iconfont icon-close"></a> - </div> -</div> - - <div class="article-wrapper page-layout"> - <div class="doc-nav"> - - - -<div class="summary"> - <h2 class="part-title"> - - é«é¶ç¥è¯ - - </h2> - <ul class="doc-summary"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/index.html" class="sidebar-link ">Weex å·¥ä½åç</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/how-data-binding-works.html" class="sidebar-link ">æ°æ®ç»å®åç</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/create-a-weex-project.html" class="sidebar-link current ">å¦ä½å建ä¸ä¸ª Weex 项ç®</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/integrate-to-android.html" class="sidebar-link ">éæå° Android</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/integrate-to-ios.html" class="sidebar-link ">éæå° iOS</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/integrate-to-html5.html" class="sidebar-link ">éæå° web</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/customize-a-native-component.html" class="sidebar-link ">èªå®ä¹ native ç»ä»¶</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/cuszomize-native-apis.html" class="sidebar-link ">èªå®ä¹ native API</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/extend-to-android.html" class="sidebar-link ">Android æ©å±</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/extend-to-ios.html" class="sidebar-link ">iOS æ©å±</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/extend-to-html5.html" class="sidebar-link ">weex-html5 æ©å±</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/integrate-devtools-to-android.html" class="sidebar-link ">éæ Devtools å° Android</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/integrate-devtools-to-ios.html" class="sidebar-link ">éæ Devtools å° iOS</a></h3> - - </li> - - - - </ul> -</div> - </div> - - -<article class="article article-type-advanced"> - <div class="article-entry" itemprop="articleBody"> - <header class="article-header"> - - - <h1 class="article-title" itemprop="name"> - å¦ä½å建ä¸ä¸ª Weex é¡¹ç® - </h1> - - - <time class="article-date" datetime="2017-04-28T02:36:21.000Z">Updated time: 28/04/2017</time> -</header> - <h1 id="å¦ä½å建ä¸ä¸ª-Weex-项ç®"><a href="#å¦ä½å建ä¸ä¸ª-Weex-项ç®" class="headerlink" title="å¦ä½å建ä¸ä¸ª Weex 项ç®"></a>å¦ä½å建ä¸ä¸ª Weex 项ç®</h1><p>对äºå端å¼åè æ¥è¯´å¼åä¸ä¸ª app æ¯ä¸å®¹æçï¼æ¢ç¶ Weex è½ä»¥ web çå¼åä½éªæ建é«æ§è½ãå¯æ©å±ç native åºç¨ï¼é£æ们æä¹å©ç¨ Weex ç®åé«æçå¼åä¸ä¸ª native åºç¨å¢ï¼Weex æ¿ä½ èèäºè¿ä»¶äºãå¨æ¬ç« ä¸ï¼æ们å°å¦ä¹ å¦ä½ä½¿ç¨ Weexpack å·¥å ·å¿«éçæä¸ä¸ªå ¨æ°ç Weex 项ç®ã</p> -<p>æ ¹æ®ä½ çæä½ç³»ç»çä¸åï¼æ¥éª¤ä¹ç¥æå·®å¼ï¼å¦æä½ ä»æªæ¥è§¦è¿ native å¼åï¼è¯·æ ¢æ ¢æ¥ï¼éå°é®é¢éæ¶æ¥é <a href="../faq.md">FAQ</a>ã</p> -<p>é¦å ï¼ä¸è®ºä»»ä½å¹³å°ï¼æ们é½éè¦ node.js å Weexpackãå¨æ¬èä¸ï¼é»è®¤ä½ å·²ç»å®è£ å¥½äº node.js å npmï¼å¦æçé®ï¼å¯åèä¸ä¸ç« <a href="../guide/develop-on-your-local-machine.html">å¦ä½å¨æ¬å°å¼å Weex 页é¢</a>ã</p> -<p>Weexpack æ¯ Weex æ°ä¸ä»£çå·¥ç¨å¼åå¥ä»¶ï¼å®å 许å¼åè éè¿ç®åçå½ä»¤ï¼å建 weex å·¥ç¨é¡¹ç®ï¼å°é¡¹ç®è¿è¡å¨ä¸åçå¼åå¹³å°ä¸ãæªæ¥ï¼æ们èèä¼å°å ¶éæå¨ weex-toolkits ä¸ï¼ä½ç®åä»éè¦åç¬å®è£ ã好å¨å®è£ Weexpack é常ç®åï¼å¯ä»¥ç´æ¥ä½¿ç¨ npm å®è£ ï¼</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line">npm install weexpack -g</div></pre></td></tr></table></figure> -<p>æè ç¨ cnpmï¼</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line">cnpm install weexpack -g</div></pre></td></tr></table></figure> -<p>æ¥ä¸æ¥çæ¥éª¤ä¼æä¸äºå¤æååºå«ï¼æ ¹æ®å¼åå¹³å°çä¸åï¼æ们æä¾äºå¿«é导èªä¾¿äºé 读ï¼</p> -<ul> -<li><a href="#ios">iOS</a></li> -<li><a href="#android">Android</a></li> -</ul> -<h2 id="iOS"><a href="#iOS" class="headerlink" title="iOS"></a>iOS</h2><p>Mac æ¯å¯ä¸å¯ä»¥å¼å iOS åºç¨çå¹³å°ï¼å æ¤å建 iOS 项ç®åªæ¯æ macãå¯¹äº iOSï¼ä½ éè¦å®è£ <a href="https://developer.apple.com/xcode/" target="_blank" rel="external">Xcode</a> å <a href="https://guides.cocoapods.org/using/getting-started.html" target="_blank" rel="external">CocoaPods</a> ã</p> -<p>å®è£ Xcode æç®åçæ¹æ³æ¯å° <a href="https://itunes.apple.com/us/app/xcode/id497799835?mt=12" target="_blank" rel="external">Mac App Store</a>ãXcode ä½ç§¯è¾å¤§ï¼ä¸è½½è¯·èå¿çå¾ ã</p> -<p>å®è£ 好 Xcode åï¼ä½ éè¦è¿è¡ Xcodeï¼ä½¿ Xcode èªå¨å®è£ å¼åè å·¥å ·å确认使ç¨åè®®ã</p> -<p>ä¹åä½ è¿éè¦å®è£ <a href="https://guides.cocoapods.org/using/getting-started.html" target="_blank" rel="external">CocoaPods</a> ãCocoaPods æ¯ Xcode 项ç®çç±»åºç®¡çå·¥å ·ï¼å¯ä»¥ä½¿ç¨å¦ä¸å½ä»¤å®è£ ï¼</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line">$ sudo gem install cocoapods</div></pre></td></tr></table></figure> -<p>å¦ææ§è¡è¯¥å½ä»¤æ ååºï¼å¾å¯è½æ¯ gem source é®é¢ï¼ä½ å¯ä»¥åæ¢ä¸ºæ·å® gem sourceï¼</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line">$ gem sources --remove https://rubygems.org/</div><div class="line">$ gem sources <span class="_">-a</span> https://ruby.taobao.org/</div><div class="line">$ sudo gem install cocoapods</div></pre></td></tr></table></figure> -<p>å¦æé®é¢ï¼å¯åè <a href="https://guides.cocoapods.org/using/getting-started.html" target="_blank" rel="external">CocoaPods å®æ¹ææ¡£</a></p> -<h3 id="å建项ç®"><a href="#å建项ç®" class="headerlink" title="å建项ç®"></a>å建项ç®</h3><p>ç¶åï¼å°±å¯ä»¥ä½¿ç¨ weexpack å建 weex å·¥ç¨äºï¼</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line">$ weexpack init appName</div></pre></td></tr></table></figure> -<p>weexpack ä¼èªå¨æ°å»ºä»¥ appName å½åçç®å½ï¼å¹¶å°é¡¹ç®æ¨¡æ¿æåå°è¯¥ç®å½ã</p> -<p>æç»å½¢æå¦ä¸ç®å½ç»æï¼</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line">-> /appName</div><div class="line">.</div><div class="line">|ââ .gitignore</div><div class="line">|ââ README.md</div><div class="line">|ââ package.json</div><div class="line">|-- android.config.json</div><div class="line">|-- ios.config.json</div><div class="line">|ââ webpack.config.js</div><div class="line">|ââ /src</div><div class="line">| |ââ index.we</div><div class="line">|ââ /html5</div><div class="line">| |ââ index.html</div><div class="line">|ââ /ios</div><div class="line">| |ââ /playground</div><div class="line">| |ââ /sdk</div><div class="line">| |ââ /WXDevtool</div><div class="line">|ââ /android</div><div class="line">| |ââ /playground</div><div class="line">| |ââ /appframework</div></pre></td></tr></table></figure> -<p>å ¶ä¸ï¼</p> -<ul> -<li><code>webpack.config.js</code> æ¯ webpack é ç½®æ件ï¼ç¨äºçæ <code>.we</code> æ件ç JSBunlde</li> -<li><code>ios.config.json</code> æ¯ iOS 项ç®é ç½®æ件</li> -<li><code>android.config.json</code> æ¯ Android 项ç®é ç½®æ件</li> -<li><code>/src</code> ç®å½æ¾ç½® Weex 页é¢</li> -<li><code>/html5</code> æ¯ H5 ç«¯å ¥å£æ件</li> -<li><code>/ios</code> æ¾ç½® iOS 项ç®</li> -<li><code>/android</code> æ¾ç½® Android 项ç®</li> -</ul> -<p>ç´§æ¥çï¼è¿å ¥ç®å½ï¼å¹¶ä¸å®è£ ä¾èµï¼</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line">$ <span class="built_in">cd</span> appName && npm install</div></pre></td></tr></table></figure> -<p>è³æ¤ï¼é¡¹ç®æ¨¡çå建å®æï¼æ¥ä¸æ¥æ们å¯ä»¥èªå®ä¹æ们ç APP ä¿¡æ¯å¹¶æå è¿è¡ã</p> -<h3 id="è¿è¡ä¸æå "><a href="#è¿è¡ä¸æå " class="headerlink" title="è¿è¡ä¸æå "></a>è¿è¡ä¸æå </h3><p>å¦æä¸åæ£å¸¸ï¼ä½ å¯ä»¥ä½¿ç¨ weexpack æå æ模æå¨è¿è¡äºï¼</p> -<p>模æå¨è¿è¡</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line">$ weexpack run ios</div></pre></td></tr></table></figure> -<p>æ建 ipa å ï¼</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line">$ weexpack build ios</div></pre></td></tr></table></figure> -<p>æ建å çè¿ç¨ä¸ï¼å°ä¼æ示让æ¨è¾å ¥ CodeSignï¼è¯ä¹¦ï¼ãProfile(provisioning profile)ãAppIdï¼åªæè¾å ¥çå®çè¿äºä¿¡æ¯æè½æåæå ã å ¶ä½å¦AppNameï¼åå ¥å£ weex bundle æ件å¯ä»¥ç¼è¾é¡¹ç®ç®å½ä¸ç <code>ios.config.json</code> é ç½®ã æå®å æåä¹åï¼å¯ä»¥å¨ <code>/playground/build/ipa_build/</code> ç®å½ä¸è·å ipa æ件ã</p> -<p>注ï¼è¯ä¹¦éè¦é¢å å®è£ å° keychain ä¸ï¼å¨ keychain ä¸ç¹å»å³é®è·åè¯ä¹¦ idï¼è¯ä¹¦å称ï¼ãprovisioning profile æ件ï¼*mobileprovisionï¼éè¦è·å UUIDï¼è¿å ¥ç®å½å¯ä»¥çå° mobileprovision_UUID.sh æ件ï¼æ¤æ件å¯ä»¥è·åå° UUIDã</p> -<p>mobileprovision_UUID.sh ç¨æ³å¦ä¸ï¼</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line">$ ./mobileprovision_UUID.sh *mobileprovision</div></pre></td></tr></table></figure> -<p>åæ°ï¼*mobileprovisionï¼ä¸º provisioning profile æ件路å¾</p> -<p><strong> 注ï¼run ä¸ build é¨åæ¶å pod çä¾èµå®è£ é®é¢ã</strong></p> -<ul> -<li>é¦å è¦å®è£ cocoapods ï¼å ·ä½å®è£ æ¥éª¤å¯æ¥ç<a href="https://cocoapods.org/" target="_blank" rel="external">è¿é</a>ï¼å»ºè®®å®è£ 0.39.0 çæ¬ã</li> -<li><p>为äºå å¿« CLI æ§è¡é度ï¼weexpack å建çå·¥ç¨é»è®¤å®è£ äºéè¦çä¾èµåºãä½æ¯å½ä»¤æ§è¡ä¾ç¶ä¼æ´æ°éè¦å级çä¾èµåºã</p> -<ul> -<li>å¦æåºç°è¿ç§é误æ示 <code>unable to find a specification for 'WeexSDK'</code> è¿ç§é误ï¼è¯´æä½ æ¬å°æ²¡ææ´æ° cocoapods master ä»åºï¼è¿è¡ <code>pod repo update</code> ï¼æ¤æ¶è¿è¡ <code>pod search WeexSDK</code>ï¼</li> -</ul> -<p><img src="https://img.alicdn.com/tps/TB1jLx4OFXXXXaoXFXXXXXXXXXX-212-33.png" alt=""> </p> -<p>说æ master repo æ´æ°æåã以ä¸æ¯ä»¥ <code>WeexSDK</code> 为ä¾ï¼å ¶ä»åºç±»ä¼¼ã</p> -<ul> -<li>å¦æåºç°è¿ç§é误 <code>error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.</code> è¿å ¥ playground ç®å½ï¼podfile æ件æå¨ç®å½ï¼ææ示æ§è¡ã</li> -</ul> -<p>æ´å¤ pod 使ç¨ç»è请移æ¥<a href="https://cocoapods.org/" target="_blank" rel="external">cocoapods</a></p> -</li> -<li><p>mobileprovisionï¼åæ°ï¼*mobileprovisionï¼ä¸º provisioning profile æ件路å¾ã</p> -</li> -</ul> -<hr> -<h2 id="Android"><a href="#Android" class="headerlink" title="Android"></a>Android</h2><p>å¨ Mac å¹³å°å¼å Android é¦å éè¦ä¸è½½ <a href="https://developer.android.com/studio/install.html" target="_blank" rel="external">Android Studio</a>ï¼ä½ å¯è½éè¦ç¿»å¢æè½è®¿é®ï¼ã<a href="https://developer.android.com/studio/install.html" target="_blank" rel="external">Android Studio</a> 为æ们æä¾äº Android SDK å AVDï¼æ¨¡æå¨ï¼ä»¥ä¾¿æ们快éè¿è¡ Android 项ç®ã</p> -<p>ä¸è½½å®æåè¿è¡ Android Studioï¼ä»»ææ°å»ºä¸ä¸ª Android 项ç®ï¼å¨ç¬¬äºæ¥ä¸éæ© <strong>Android 5.1</strong>ï¼ç¶åç¹å» next å®æ项ç®å建ï¼å¦å¾æ示ï¼</p> -<p><img src="https://gw.alicdn.com/tps/TB1VulhOFXXXXcPXFXXXXXXXXXX-828-686.png" alt="android"> </p> -<p>å¾ Android Studio æå¼åï¼å¨é¡¶é¨èåæ éæ© Tools -> Android -> AVD Managerï¼å®è£ Android 模æå¨ï¼</p> -<p><img src="https://img.alicdn.com/tps/TB1CBdgOFXXXXXnXVXXXXXXXXXX-661-392.jpg" alt="android"></p> -<p>ä¹åï¼æå¼æ¨¡æå¨è¿è¡ Androidã</p> -<p><strong>注æï¼</strong></p> -<ol> -<li>å¿ é¡»ä¿æ模æå¨è¿è¡ã</li> -<li>ä¿è¯ Android build-tool ççæ¬ä¸º 23.0ããå¯ä»¥å¨ Android Studio ç SDK Manager éæ¥çæ¯å¦å·²å®è£ è¿ä¸ªçæ¬ï¼å¦æ没æå¯éæ©å®è£ è¿ä¸çæ¬ãã</li> -</ol> -<h3 id="é ç½®ç¯å¢åé"><a href="#é ç½®ç¯å¢åé" class="headerlink" title="é ç½®ç¯å¢åé"></a>é ç½®ç¯å¢åé</h3><p>å 为 Android Studio å®è£ ç SDK ä¸ä¼èªå¨é ç½®ç¯å¢åéï¼ä½ èªå·±å®è£ ç SDK åæ ·ä¸ä¼ï¼ãæ以éè¦æ¨èªå·±æå¨é ç½® Android_HOME ç¯å¢åéå PATH </p> -<p>å¦ææ¯ Android Studio å®è£ ç SDK å®è£ è·¯å¾å¯å·²å¨ SDK manager éæ¾å°ï¼æå¼ SDK manager çæ¹å¼è¯·åç §å¾2ï¼</p> -<p>Windows ä¸è¯·åç § <a href="http://jingyan.baidu.com/article/09ea3ede1b4df6c0aede39ab.html" target="_blank" rel="external">window ä¸å¦ä½è®¾ç½® ANDROID ç¯å¢åé</a></p> -<p>Linux/Mac ä¸åªéç¼è¾ <code>.bash_profile</code> å¢å PATH å³å¯ï¼</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line">vim ~/.bash_profile</div></pre></td></tr></table></figure> -<p>ç¶åæ·»å ä¸å代ç è¿å»ï¼è·¯å¾æ¿æ¢ä¸ºä½ ççå®è·¯å¾ï¼</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line"><span class="built_in">export</span> ANDROID_HOME=/xxx/Library/Android/sdk</div><div class="line"><span class="built_in">export</span> PATH=<span class="variable">${PATH}</span>:<span class="variable">$ANDROID_HOME</span>/tools:<span class="variable">$ANDROID_HOME</span>/platform-tools:<span class="variable">$ANDROID_HOME</span>/build-tools</div></pre></td></tr></table></figure> -<p>ç¶åä¿åéåºï¼:wqï¼ãåæ§è¡ä¸åå½ä»¤ï¼</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line"><span class="built_in">source</span> ~/.bash_profile</div></pre></td></tr></table></figure> -<h3 id="å建项ç®-1"><a href="#å建项ç®-1" class="headerlink" title="å建项ç®"></a>å建项ç®</h3><p>ç¶åï¼å°±å¯ä»¥ä½¿ç¨ weexpack å建 weex å·¥ç¨äºï¼</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line">$ weexpack init appName</div></pre></td></tr></table></figure> -<p>weexpack ä¼èªå¨æ°å»ºä»¥ appName å½åçç®å½ï¼å¹¶å°é¡¹ç®æ¨¡æ¿æåå°è¯¥ç®å½ã</p> -<p>æç»å½¢æå¦ä¸ç®å½ç»æï¼</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line">-> /appName</div><div class="line">.</div><div class="line">|ââ .gitignore</div><div class="line">|ââ README.md</div><div class="line">|ââ package.json</div><div class="line">|-- android.config.json</div><div class="line">|-- ios.config.json</div><div class="line">|ââ webpack.config.js</div><div class="line">|ââ /src</div><div class="line">| |ââ index.we</div><div class="line">|ââ /html5</div><div class="line">| |ââ index.html</div><div class="line">|ââ /ios</div><div class="line">| |ââ /playground</div><div class="line">| |ââ /sdk</div><div class="line">| |ââ /WXDevtool</div><div class="line">|ââ /android</div><div class="line">| |ââ /playground</div><div class="line">| |ââ /appframework</div></pre></td></tr></table></figure> -<p>å ¶ä¸ï¼</p> -<ul> -<li><code>webpack.config.js</code> æ¯ webpack é ç½®æ件ï¼ç¨äºçæ <code>.we</code> æ件ç JSBunlde</li> -<li><code>ios.config.json</code> æ¯ iOS 项ç®é ç½®æ件</li> -<li><code>android.config.json</code> æ¯ Android 项ç®é ç½®æ件</li> -<li><code>/src</code> ç®å½æ¾ç½® Weex 页é¢</li> -<li><code>/html5</code> æ¯ H5 ç«¯å ¥å£æ件</li> -<li><code>/ios</code> æ¾ç½® iOS 项ç®</li> -<li><code>/android</code> æ¾ç½® Android 项ç®</li> -</ul> -<p>ç´§æ¥çï¼è¿å ¥ç®å½ï¼å¹¶ä¸å®è£ ä¾èµï¼</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line">$ <span class="built_in">cd</span> appName && npm install</div></pre></td></tr></table></figure> -<p>è³æ¤ï¼é¡¹ç®æ¨¡çå建å®æï¼æ¥ä¸æ¥æ们å¯ä»¥èªå®ä¹æ们ç APP ä¿¡æ¯å¹¶æå è¿è¡ã</p> -<h3 id="è¿è¡ä¸æå -1"><a href="#è¿è¡ä¸æå -1" class="headerlink" title="è¿è¡ä¸æå "></a>è¿è¡ä¸æå </h3><p>å¦æä¸åæ£å¸¸ï¼ä½ å¯ä»¥ä½¿ç¨ weexpack æå æ模æå¨è¿è¡äºï¼</p> -<p>Android çæå åæ建æ¯ä¸ä½ç ï¼</p> -<figure class="highlight bash"><table><tr><td class="code"><pre><div class="line">$ weexpack run android</div></pre></td></tr></table></figure> -<p>åæ ·çä½ å¯ä»¥æ´æ¹é¡¹ç®ç®å½ä¸çandroid.config.json</p> -<ul> -<li><code>AppName</code>: åºç¨å</li> -<li><code>AppId</code>: application_id å å</li> -<li><code>SplashText</code>: 欢è¿é¡µä¸é¢çæå</li> -<li><p><code>WeexBundle</code>: æå®ç weex bundle æ件ï¼æ¯ææ件åå url çå½¢å¼ï¼</p> -<p>æå®æ件åå以æ¬å°æ件çæ¹å¼å è½½ bundleï¼æå® url å以è¿ç¨çæ¹å¼å è½½ JSBundleãå¦æ以æ¬å°æ¹å¼æå® bundle <code>.we</code> æ件请æ¾å° <code>src</code> ç®å½ã</p> -</li> -</ul> - - </div> - -</article> -</div> - - <footer id="footer"> - <div class="row clearfix"> - <div class="dropdown select-lang"> - <a href="javascript:;" class="dropdown-toggle"> - Language - <span class="caret"></span> - </a> - <ul class="dropdown-menu pick-lang"> - <li> - <a href="/v-0.10/advanced/create-a-weex-project.html" data-lang="en">English</a> - </li> - <li> - <a href="/cn/v-0.10/advanced/create-a-weex-project.html" data-lang="zh-cn">ä¸æ</a> - </li> - </ul> - </div> - </div> - <div class="disclaimer"> - <div><img src="//gw.alicdn.com/tfs/TB1pTBZQFXXXXX9XXXXXXXXXXXX-794-280.png" width="200px" alt="Apache Incubator"></div> - <div><span class="title">Disclaimer:</span> Apache Weex is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.</div> - <br/> - </div> - <hr> - <div class="row"> - <p> <img src="//gw.alicdn.com/tfs/TB1bg8SQFXXXXcHXXXXXXXXXXXX-85-170.png" height="50px" alt="Apache"><span>Copyright(c) 2017 The Apache Software Foundation. Licensed under the </span> <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a></p> - </div> - <div class="row clearfix"> - <div></div> - </div> -</footer> - <div style="display: none;"> - <script src="//s95.cnzz.com/z_stat.php?id=1261496509&web_id=1261496509" language="JavaScript"></script> -</div> - - <script src="/js/reqwest.js"></script> - <script src="/js/common.js"></script> -</body> -</html>
http://git-wip-us.apache.org/repos/asf/incubator-weex-site/blob/f3d58bd0/cn/v-0.10/advanced/customize-a-native-component.html ---------------------------------------------------------------------- diff --git a/cn/v-0.10/advanced/customize-a-native-component.html b/cn/v-0.10/advanced/customize-a-native-component.html deleted file mode 100644 index 6607dbb..0000000 --- a/cn/v-0.10/advanced/customize-a-native-component.html +++ /dev/null @@ -1,462 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <meta charset="utf-8"> - - <title>èªå®ä¹ native ç»ä»¶ | Weex</title> - <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> - <meta name="description" content="å¦ä½èªå®ä¹ native ç»ä»¶ï¼Weex å·²ç»å å«äºæå ³é®çå¹³å°ç»ä»¶ï¼ä¾å¦ ScrollView, ListView, Text, Imageview ççãå½ç¶ï¼è¿äºç»ä»¶å¹¶ä¸è½å®å ¨æ»¡è¶³ä½ çéæ±ãå¦å¤ï¼é£äºå¨ä½ çå·¥ç¨ä¸å¸¸ç¨ç大éåç UI ç»ä»¶ï¼å¯è½éè¦è¢«ç®åå°éåå° Weex ä¸ã幸è¿çæ¯ï¼éè¿ä»»æå·²åå¨çç»ä»¶æ¥åå»ºä½ çèªå®ä¹ç»ä»¶æ¯ä¸ä»¶å¾æ¹ä¾¿çäºã Androidæ¥éª¤ï¼1.èªå®ä¹ç»ä»¶å¿ 须继æ¿èª"> -<meta property="og:type" content="website"> -<meta property="og:title" content="èªå®ä¹ native ç»ä»¶"> -<meta property="og:url" content="https://weex-project.io/cn/v-0.10/advanced/customize-a-native-component.html"> -<meta property="og:site_name" content="Weex"> -<meta property="og:description" content="å¦ä½èªå®ä¹ native ç»ä»¶ï¼Weex å·²ç»å å«äºæå ³é®çå¹³å°ç»ä»¶ï¼ä¾å¦ ScrollView, ListView, Text, Imageview ççãå½ç¶ï¼è¿äºç»ä»¶å¹¶ä¸è½å®å ¨æ»¡è¶³ä½ çéæ±ãå¦å¤ï¼é£äºå¨ä½ çå·¥ç¨ä¸å¸¸ç¨ç大éåç UI ç»ä»¶ï¼å¯è½éè¦è¢«ç®åå°éåå° Weex ä¸ã幸è¿çæ¯ï¼éè¿ä»»æå·²åå¨çç»ä»¶æ¥åå»ºä½ çèªå®ä¹ç»ä»¶æ¯ä¸ä»¶å¾æ¹ä¾¿çäºã Androidæ¥éª¤ï¼1.èªå®ä¹ç»ä»¶å¿ 须继æ¿èª"> -<meta property="og:updated_time" content="2017-04-28T02:36:21.000Z"> -<meta name="twitter:card" content="summary"> -<meta name="twitter:title" content="èªå®ä¹ native ç»ä»¶"> -<meta name="twitter:description" content="å¦ä½èªå®ä¹ native ç»ä»¶ï¼Weex å·²ç»å å«äºæå ³é®çå¹³å°ç»ä»¶ï¼ä¾å¦ ScrollView, ListView, Text, Imageview ççãå½ç¶ï¼è¿äºç»ä»¶å¹¶ä¸è½å®å ¨æ»¡è¶³ä½ çéæ±ãå¦å¤ï¼é£äºå¨ä½ çå·¥ç¨ä¸å¸¸ç¨ç大éåç UI ç»ä»¶ï¼å¯è½éè¦è¢«ç®åå°éåå° Weex ä¸ã幸è¿çæ¯ï¼éè¿ä»»æå·²åå¨çç»ä»¶æ¥åå»ºä½ çèªå®ä¹ç»ä»¶æ¯ä¸ä»¶å¾æ¹ä¾¿çäºã Androidæ¥éª¤ï¼1.èªå®ä¹ç»ä»¶å¿ 须继æ¿èª"> - - <link rel="alternate" href="/atom.xml" title="Weex" type="application/atom+xml"> - - - <link rel="icon" href="//gw.alicdn.com/tps/TB1XNqxPXXXXXcSXVXXXXXXXXXX-64-63.png"> - - - <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css"> - - <link rel="stylesheet" href="/css/style.css"> - <link rel="stylesheet" href="/css/swiper.min.css"> -</head> - -<body id="advanced" class="lang-cn"> - - <script> - window.PAGE_TYPE = "advanced"; - window.ROOT = "/" - </script> - <header id="header"> - <div class="navbar"> - <a id="logo" href="/cn/"> - <img src="//img.alicdn.com/tps/TB1zBLaPXXXXXXeXXXXXXXXXXXX-121-59.svg" /> - </a> - <div class="main-nav"> - <ul class="links"> - <li><a href="/cn/guide">æç¨</a></li> - <li><a href="/cn/references">æå</a></li> - <li class="dropdown"> - <a href="javascript:;">åè</a> - <ul class="dropdown-menu subnav"> - <li> - <a href="/cn/faq.html">FAQ</a> - </li> - <li> - <a href="/cn/releasenote.html">çæ¬è¯´æ</a> - </li> - </ul> - </li> - <li class="dropdown"> - <a href="javascript:;">å·¥å ·åæå¡</a> - <ul class="dropdown-menu subnav"> - <li> - <a href="/cn/playground.html">Playground</a> - </li> - <li> - <a href="/cn/guide/tools/toolkit.html">Weex-toolkit</a> - </li> - <li> - <a href="http://dotwe.org" target="_blank">Code Snippets</a> - </li> - <li> - <a href="https://market.dotwe.org" target="_blank">Market</a> - </li> - </ul> - </li> - </ul> - <ul class="info"> - <li><a href="https://github.com/apache/incubator-weex/" target="_blank"><span class="btn-github iconfont icon-github"></span></a></li> - </ul> - <ul class="tools"> - <li> - <div class="search"> - <form id="search-form" class="search-form"> <!-- æç´¢æ¡ç¸å ³ --> - <input type="text" id="search-input-header" name="q" results="0" class="form-control search-input" autocomplete="off" autocorrect="off"/> - <span class="iconfont icon-search"></span> - </form> - <div class="results-panel"> - </div> -</div> - </li> - <li> - <div class="dropdown select-lang"> - <a href="javascript:;" class="dropdown-toggle"> - Language - <span class="caret"></span> - </a> - <ul class="dropdown-menu pick-lang"> - <li> - <a href="/v-0.10/advanced/customize-a-native-component.html" data-lang="en">English</a> - </li> - <li> - <a href="/cn/v-0.10/advanced/customize-a-native-component.html" data-lang="zh-cn">ä¸æ</a> - </li> - </ul> - </div> - </li> - <!--<li></li>--> - </ul> - </div> - </div> - <div id="mobile-nav"> - <a id="logo" href="/cn/"> - <img src="//img.alicdn.com/tps/TB1zBLaPXXXXXXeXXXXXXXXXXXX-121-59.svg" /> - </a> - <a class="btn-menu"><span class="iconfont icon-nav"></span></a> - </div> -</header> - - <div id="sidebar" class=""> - <div class="sidebar-menu"> - - <ul class="main-nav"> - <li> - <div class="search"> - <form id="search-form" class="search-form"> <!-- æç´¢æ¡ç¸å ³ --> - <input type="text" id="search-input-sidebar" name="q" results="0" class="form-control search-input" autocomplete="off" autocorrect="off"/> - <span class="iconfont icon-search"></span> - </form> - <div class="results-panel"> - </div> -</div> - </li> - <li> - <a class="" href="/cn/guide"> - æç¨ - </a> - </li> - <li> - <a class="" href="/cn/references"> - æå - </a> - </li> - <li> - <a href="/cn/faq.html"> - FAQ - </a> - </li> - <li> - <p>å·¥å ·åæå¡</p> - <ul class="subnav"> - <li> - <a href="/cn/playground.html">Playground</a> - </li> - <li> - <a href="/cn/guide/tools/devtools.html">Devtools</a> - </li> - <li> - <a href="/cn/guide/tools/weexpack.html">Weexpack</a> - </li> - <li> - <a href="http://dotwe.org" target="_blank">Snippets</a> - </li> - <li> - <a href="https://market.dotwe.org" target="_blank">Market</a> - </li> - </ul> - </li> - <li> - <a href="https://github.com/apache/incubator-weex/" target="_blank"> - GitHub - </a> - </li> - </ul> - - <a class="btn-close-sidebar iconfont icon-close"></a> - </div> -</div> - - <div class="article-wrapper page-layout"> - <div class="doc-nav"> - - - -<div class="summary"> - <h2 class="part-title"> - - é«é¶ç¥è¯ - - </h2> - <ul class="doc-summary"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/index.html" class="sidebar-link ">Weex å·¥ä½åç</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/how-data-binding-works.html" class="sidebar-link ">æ°æ®ç»å®åç</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/create-a-weex-project.html" class="sidebar-link ">å¦ä½å建ä¸ä¸ª Weex 项ç®</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/integrate-to-android.html" class="sidebar-link ">éæå° Android</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/integrate-to-ios.html" class="sidebar-link ">éæå° iOS</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/integrate-to-html5.html" class="sidebar-link ">éæå° web</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/customize-a-native-component.html" class="sidebar-link current ">èªå®ä¹ native ç»ä»¶</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/cuszomize-native-apis.html" class="sidebar-link ">èªå®ä¹ native API</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/extend-to-android.html" class="sidebar-link ">Android æ©å±</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/extend-to-ios.html" class="sidebar-link ">iOS æ©å±</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/extend-to-html5.html" class="sidebar-link ">weex-html5 æ©å±</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/integrate-devtools-to-android.html" class="sidebar-link ">éæ Devtools å° Android</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/integrate-devtools-to-ios.html" class="sidebar-link ">éæ Devtools å° iOS</a></h3> - - </li> - - - - </ul> -</div> - </div> - - -<article class="article article-type-advanced"> - <div class="article-entry" itemprop="articleBody"> - <header class="article-header"> - - - <h1 class="article-title" itemprop="name"> - èªå®ä¹ native ç»ä»¶ - </h1> - - - <time class="article-date" datetime="2017-04-28T02:36:21.000Z">Updated time: 28/04/2017</time> -</header> - <h1 id="å¦ä½èªå®ä¹-native-ç»ä»¶ï¼"><a href="#å¦ä½èªå®ä¹-native-ç»ä»¶ï¼" class="headerlink" title="å¦ä½èªå®ä¹ native ç»ä»¶ï¼"></a>å¦ä½èªå®ä¹ native ç»ä»¶ï¼</h1><p>Weex å·²ç»å å«äºæå ³é®çå¹³å°ç»ä»¶ï¼ä¾å¦ <code>ScrollView, ListView, Text, Imageview</code> ççãå½ç¶ï¼è¿äºç»ä»¶å¹¶ä¸è½å®å ¨æ»¡è¶³ä½ çéæ±ãå¦å¤ï¼é£äºå¨ä½ çå·¥ç¨ä¸å¸¸ç¨ç大éåç UI ç»ä»¶ï¼å¯è½éè¦è¢«ç®åå°éåå° Weex ä¸ã幸è¿çæ¯ï¼éè¿ä»»æå·²åå¨çç»ä»¶æ¥åå»ºä½ çèªå®ä¹ç»ä»¶æ¯ä¸ä»¶å¾æ¹ä¾¿çäºã</p> -<h2 id="Android"><a href="#Android" class="headerlink" title="Android"></a>Android</h2><h3 id="æ¥éª¤ï¼"><a href="#æ¥éª¤ï¼" class="headerlink" title="æ¥éª¤ï¼"></a>æ¥éª¤ï¼</h3><p>1.èªå®ä¹ç»ä»¶å¿ 须继æ¿èª <code>WXComponent</code> æè <code>WXContainer</code> ï¼<br>2.weex SDK å¯ä»¥è¯å« @WXComponentProp (name = value(value æ¯ attr æè dsl style))ï¼<br>3.æ¹æ³å¿ é¡»æ¯ <code>public</code> çï¼<br>4.ç»ä»¶ç±»ä¸è½æ¯ä¸ä¸ªå é¨ç±»ï¼<br>5.èªå®ä¹ç»ä»¶ä¸è½è¢« ProGuard ä¹ç±»çå·¥å ·æ··æ·ï¼<br>6.ç»ä»¶æ¹æ³å¨ UI 线ç¨è¢«è°ç¨ï¼å æ¤ä¸è¦å¨éé¢è¿è¡èæ¶çæä½ï¼<br>7.Weex çåæ°ç±»åå¯ä»¥æ¯ int, double, float, String, Map, List åå®ç°äº WXObject æ¥å£çèªå®ä¹ç±»ï¼</p> -<h3 id="åè以ä¸ä¾åï¼"><a href="#åè以ä¸ä¾åï¼" class="headerlink" title="åè以ä¸ä¾åï¼"></a>åè以ä¸ä¾åï¼</h3><figure class="highlight java"><table><tr><td class="code"><pre><div class="line"> `<span class="keyword">package</span> com.taobao.weex.ui.component;</div><div class="line"><span class="comment">// â¦â¦</span></div><div class="line"></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">MyViewComponent</span> <span class="keyword">extends</span> <span class="title">WXComponent</span></span>{</div><div class="line"></div><div class="line"> <span class="function"><span class="keyword">public</span> <span class="title">MyViewComponent</span><span class="params">(WXSDKInstance instance, WXDomObject node, </span></span></div><div class="line"> WXVContainer parent, String instanceId, <span class="keyword">boolean</span> lazy) { </div><div class="line"> <span class="keyword">super</span>(instance, node, parent, instanceId, lazy);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="meta">@Override</span></div><div class="line"> <span class="function"><span class="keyword">protected</span> <span class="keyword">void</span> <span class="title">initView</span><span class="params">()</span> </span>{</div><div class="line"> <span class="comment">//<span class="doctag">TODO:</span>your own code â¦â¦</span></div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="meta">@Override</span></div><div class="line"> <span class="function"><span class="keyword">public</span> WXFrameLayout <span class="title">getView</span><span class="params">()</span> </span>{</div><div class="line"> <span class="comment">//<span class="doctag">TODO:</span>your own code â¦â¦â¦ </span></div><div class="line"> }</div><div class="line"> <span class="meta">@WXComponentProp</span>(name=WXDomPropConstant.WX_ATTR_VALUE)</div><div class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setMyViewValue</span><span class="params">(String value)</span> </span>{</div><div class="line"> ((TextView)mHost).setText(value);</div><div class="line"> }</div><div class="line"></div><div class="line">}</div></pre></td></tr></table></figure> -<p>å¿ é¡»æ³¨åç»ä»¶ï¼</p> -<figure class="highlight java"><table><tr><td class="code"><pre><div class="line">WXSDKEngine.registerComponent(<span class="string">"MyView"</span>, MyViewComponent.class);</div></pre></td></tr></table></figure> -<h2 id="iOS"><a href="#iOS" class="headerlink" title="iOS"></a>iOS</h2><p>è½ç¶ WeexSDK ä¸æå¾å¤ç native ç Componentï¼ä½è¿æå¯è½å¹¶ä¸è½æ»¡è¶³ä½ çéæ±ãå¨ä¹åä½ å¯è½å·²ç»åäºä¸äºå¾é ·ç« native çç»ä»¶ï¼æ³å è£ ä¸ä¸ï¼å¯¼å ¥å° Weex ä¸ï¼å æ¤æ们æä¾äºè®©å¼åè å®ç°èªå·±ç native Componentãä¸é¢å°ä»¥ WeexSDK ä¸å·²ç»åå¨ç Componentï¼<code>image</code> 为ä¾åï¼ä»ç»ä¸ä¸å¦ä½æ建ä¸ä¸ª native Componentãåè®¾ä½ å·²ç»äºè§£ iOS å¼å</p> -<h3 id="注å-Component"><a href="#注å-Component" class="headerlink" title="注å Component"></a>注å Component</h3><p>注åä¸ä¸ª component æ¯è¾ç®åï¼è°ç¨ <code>WXSDKEngine</code> ä¸ç <code>registerComponent:withClass:</code> æ¹æ³ï¼ä¼ å ¥ç»ä»¶çæ ç¾å称ï¼è¿æ对åºç class ç¶åä½ å¯ä»¥å建ä¸ä¸ª <code>WXImageComponent</code> 表示 <code>image</code> ç»ä»¶çå®ç°ãå¨ <code>.we</code> æ件ä¸ï¼åªéè¦å <code><image></image></code></p> -<h3 id="æ·»å å±æ§"><a href="#æ·»å å±æ§" class="headerlink" title="æ·»å å±æ§"></a>æ·»å å±æ§</h3><p>ç°å¨æ们è¦åä¸äºè®© image component æ´å 强大çäºæ ãæ¢ç¶ä½ä¸ºä¸ä¸ªå¾çç componentï¼é£å®åºè¯¥è¦ææºï¼ç»ä»å ä¸ä¸ä¸ª <code>src</code> çå±æ§ï¼åæ¶ç»å®å ä¸ä¸ä¸ª <code>resize</code> çå±æ§ï¼å¯ä»¥é ç½®çæ <code>contain/cover/stretch</code>ï¼</p> -<figure class="highlight plain"><table><tr><td class="code"><pre><div class="line">@interface WXImageComponent ()</div><div class="line"></div><div class="line">@property (nonatomic, strong) NSString *imageSrc;</div><div class="line">@property (nonatomic, assign) UIViewContentMode resizeMode;</div><div class="line"></div><div class="line">@end</div></pre></td></tr></table></figure> -<p>component ä¸ææç styleï¼attributeï¼events é½ä¼è¢«ä¼ éå° Component çåå§åæ¹æ³ä¸ï¼æ以ï¼ä½ å¯ä»¥å¨åå§åæ¹æ³ä¸åå¨ä½ æå ´è¶£çä¸äºå±æ§å¼</p> -<figure class="highlight plain"><table><tr><td class="code"><pre><div class="line">@implementation WXImageComponent</div><div class="line"></div><div class="line">- (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDictionary *)styles attributes:(NSDictionary *)attributes events:(NSArray *)events weexInstance:(WXSDKInstance *)weexInstance</div><div class="line">{</div><div class="line"> if (self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance]) {</div><div class="line"> _imageSrc = [WXConvert NSString:attributes[@"src"]];</div><div class="line"> _resizeMode = [WXConvert UIViewContentMode:attributes[@"resize"]];</div><div class="line">}</div><div class="line"></div><div class="line"> return self;</div><div class="line">}</div><div class="line"></div><div class="line">@end</div></pre></td></tr></table></figure> -<p>attribute ä¸æ¿å°çå¼çç±»åé½æ¯ <code>id</code>ï¼æ们å¯ä»¥ç¨è½¬æ¢æ¹æ³æå®è½¬æ¢å°ä»»ä½å¼ãWeex SDK æä¾äºä¸äºåºç¡ç转æ¢æ¹æ³ï¼å¯ä»¥åè <code>WXConvert</code> ç±»ï¼æè ä½ å¯ä»¥æ·»å èªå·±ç转æ¢å½æ°ã</p> -<h3 id="Hooking-渲æçå½å¨æ"><a href="#Hooking-渲æçå½å¨æ" class="headerlink" title="Hooking 渲æçå½å¨æ"></a>Hooking 渲æçå½å¨æ</h3><p>native ç component æ¯ç± Weex 管ççï¼Weex å建ï¼å¸å±ï¼æ¸²æï¼éæ¯ãWeex ç component çå½å¨æé½æ¯å¯ä»¥ hook çï¼ä½ å¯ä»¥å¨è¿äºçå½å¨æä¸å»åèªå·±çäºæ ã</p> -<table> -<thead> -<tr> -<th style="text-align:center">æ¹æ³</th> -<th>æè¿°</th> -</tr> -</thead> -<tbody> -<tr> -<td style="text-align:center">initWithRef:type:â¦</td> -<td>ç¨ç»å®çå±æ§åå§åä¸ä¸ªcomponent.</td> -</tr> -<tr> -<td style="text-align:center">layoutDidFinish</td> -<td>å¨componentå®æå¸å±æ¶åä¼è°ç¨.</td> -</tr> -<tr> -<td style="text-align:center">loadView</td> -<td>å建component管ççview.</td> -</tr> -<tr> -<td style="text-align:center">viewWillLoad</td> -<td>å¨componentçviewå è½½ä¹åä¼è°ç¨.</td> -</tr> -<tr> -<td style="text-align:center">viewDidLoad</td> -<td>å¨componentçviewå è½½å®ä¹åè°ç¨.</td> -</tr> -<tr> -<td style="text-align:center">viewWillUnload</td> -<td>å¨componentçview被éæ¾ä¹åè°ç¨.</td> -</tr> -<tr> -<td style="text-align:center">viewDidUnload</td> -<td>å¨componentçview被éæ¾ä¹åè°ç¨.</td> -</tr> -<tr> -<td style="text-align:center">updateStyles:</td> -<td>å¨componentçstyleæ´æ°æ¶åè°ç¨.</td> -</tr> -<tr> -<td style="text-align:center">updateAttributes:</td> -<td>å¨componentçattributeæ´æ°æ¶åè°ç¨.</td> -</tr> -<tr> -<td style="text-align:center">addEvent:</td> -<td>ç»componentæ·»å eventçæ¶åè°ç¨.</td> -</tr> -<tr> -<td style="text-align:center">removeEvent:</td> -<td>å¨event移é¤çæ¶åè°ç¨.</td> -</tr> -</tbody> -</table> -<p>å¨ image component çä¾åéé¢ï¼å¦ææ们éè¦æ们èªå·±ç image view çè¯ï¼å¯ä»¥å¤å <code>loadView</code>è¿ä¸ªæ¹æ³.</p> -<figure class="highlight plain"><table><tr><td class="code"><pre><div class="line">- (UIView *)loadView</div><div class="line">{</div><div class="line">return [[WXImageView alloc] init];</div><div class="line">}</div></pre></td></tr></table></figure> -<p>ç°å¨æä»¬ä½¿ç¨ <code>WXImageView</code> 渲æ <code>image</code> componentã<br>ä½ä¸ºä¸ä¸ª image componentï¼æ们éè¦æ¿å°æå¡å¨å¾çï¼èä¸æå®è®¾ç½®è¿ image view é. è¿ä¸ªæä½å¯ä»¥å¨ <code>viewDidLoad</code> æ¹æ³ä¸åï¼è¿ä¸ªæ¹æ³æ¯å¨ view å·²ç»è¢«å建èä¸å è½½äºæ¶å Weex SDK ä¼è°ç¨å°ï¼èä¸ <code>viewDidLoad</code> è¿ä¸ªæ¹æ³æ¯ä½ åé¢å¤åå§åå·¥ä½æ¯å¦æ¹å content mode(ä¹å°±æ¯è®¾ç½®resize) çæ好æ¶é´.</p> -<figure class="highlight plain"><table><tr><td class="code"><pre><div class="line">- (void)viewDidLoad</div><div class="line">{</div><div class="line"> UIImageView *imageView = (UIImageView *)self.view;</div><div class="line"> imageView.contentMode = _resizeMode;</div><div class="line"> imageView.userInteractionEnabled = YES;</div><div class="line"> imageView.clipsToBounds = YES;</div><div class="line"> imageView.exclusiveTouch = YES;</div><div class="line"></div><div class="line"> // Do your image fetching and updating logic</div><div class="line">}</div></pre></td></tr></table></figure> -<p>å¦æå¯ä»¥æ¹å image ç srcï¼ä¹å¯ä»¥ hook <code>updateAttributes:</code> æ¹æ³æ¥åå±æ§æ´æ°æä½ï¼å½ <code>updateAttributes:</code> æè <code>updateStyles:</code> 被è°ç¨çæ¶åï¼ component ç view å·²ç»å è½½å®æ</p> -<figure class="highlight plain"><table><tr><td class="code"><pre><div class="line">- (void)updateAttributes:(NSDictionary *)attributes</div><div class="line">{</div><div class="line"> if (attributes[@"src"]) {</div><div class="line"> _imageSrc = [WXConvert NSString:attributes[@"src"]];</div><div class="line"> // Do your image updating logic</div><div class="line"> }</div><div class="line"></div><div class="line"> if (attributes[@"resize"]) {</div><div class="line"> _resizeMode = [WXConvert UIViewContentMode:attributes[@"resize"]];</div><div class="line"> self.view.contentMode = _resizeMode;</div><div class="line"> }</div><div class="line">}</div></pre></td></tr></table></figure> -<p>æè®¸ä½ éè¦èèæ´å¤ççå½å¨ææ¹æ³å» Hookï¼å½å¸å±å®ææ¶åï¼å <code>layoutDidFinish</code>ï¼å¦æä½ æ³äºè§£æ´å¤ï¼å¯ä»¥åèä¸ä¸<code>WXComponent.h</code> 声æçæ¹æ³ã</p> -<p>ç°å¨ä½ å¯ä»¥ç¨å¨ä»»ä½ <code>.we</code> æ件éé¢ä½¿ç¨ <code><image></code>ï¼èä¸å¯ä»¥å ä¸ image çå±æ§ã</p> -<figure class="highlight html"><table><tr><td class="code"><pre><div class="line"><span class="tag"><<span class="name">image</span> <span class="attr">style</span>=<span class="string">"your-custom-style"</span> <span class="attr">src</span>=<span class="string">"image-remote-source"</span> <span class="attr">resize</span>=<span class="string">"contain/cover/stretch"</span>></span><span class="tag"></<span class="name">image</span>></span></div></pre></td></tr></table></figure> - - </div> - -</article> -</div> - - <footer id="footer"> - <div class="row clearfix"> - <div class="dropdown select-lang"> - <a href="javascript:;" class="dropdown-toggle"> - Language - <span class="caret"></span> - </a> - <ul class="dropdown-menu pick-lang"> - <li> - <a href="/v-0.10/advanced/customize-a-native-component.html" data-lang="en">English</a> - </li> - <li> - <a href="/cn/v-0.10/advanced/customize-a-native-component.html" data-lang="zh-cn">ä¸æ</a> - </li> - </ul> - </div> - </div> - <div class="disclaimer"> - <div><img src="//gw.alicdn.com/tfs/TB1pTBZQFXXXXX9XXXXXXXXXXXX-794-280.png" width="200px" alt="Apache Incubator"></div> - <div><span class="title">Disclaimer:</span> Apache Weex is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.</div> - <br/> - </div> - <hr> - <div class="row"> - <p> <img src="//gw.alicdn.com/tfs/TB1bg8SQFXXXXcHXXXXXXXXXXXX-85-170.png" height="50px" alt="Apache"><span>Copyright(c) 2017 The Apache Software Foundation. Licensed under the </span> <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a></p> - </div> - <div class="row clearfix"> - <div></div> - </div> -</footer> - <div style="display: none;"> - <script src="//s95.cnzz.com/z_stat.php?id=1261496509&web_id=1261496509" language="JavaScript"></script> -</div> - - <script src="/js/reqwest.js"></script> - <script src="/js/common.js"></script> -</body> -</html> http://git-wip-us.apache.org/repos/asf/incubator-weex-site/blob/f3d58bd0/cn/v-0.10/advanced/cuszomize-native-apis.html ---------------------------------------------------------------------- diff --git a/cn/v-0.10/advanced/cuszomize-native-apis.html b/cn/v-0.10/advanced/cuszomize-native-apis.html deleted file mode 100644 index c8fa64c..0000000 --- a/cn/v-0.10/advanced/cuszomize-native-apis.html +++ /dev/null @@ -1,408 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <meta charset="utf-8"> - - <title>èªå®ä¹ native API | Weex</title> - <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> - <meta name="description" content="å¦ä½èªå®ä¹ native APIï¼Weex ç SDK åªæä¾äºé¡µé¢æ¸²æçè½åï¼ä½æ¯ä¸äºå ¶å®æä½ï¼æ¯å¦ç½ç»è¯·æ±ãå¾çå è½½ãéå®åçåè½éè¦ä½ èªå·±å»å®ç°ï¼è¿ä¸ªä¾å讲述äºå¦ä½ç¨åç代ç å»æ©å± Weex çåè½ã å ³äº URLHelper çä¾åæ°å»ºä¸ä¸ª WXModulepublic class URLHelperModule extends WXModule&#123; private stat"> -<meta property="og:type" content="website"> -<meta property="og:title" content="èªå®ä¹ native API"> -<meta property="og:url" content="https://weex-project.io/cn/v-0.10/advanced/cuszomize-native-apis.html"> -<meta property="og:site_name" content="Weex"> -<meta property="og:description" content="å¦ä½èªå®ä¹ native APIï¼Weex ç SDK åªæä¾äºé¡µé¢æ¸²æçè½åï¼ä½æ¯ä¸äºå ¶å®æä½ï¼æ¯å¦ç½ç»è¯·æ±ãå¾çå è½½ãéå®åçåè½éè¦ä½ èªå·±å»å®ç°ï¼è¿ä¸ªä¾å讲述äºå¦ä½ç¨åç代ç å»æ©å± Weex çåè½ã å ³äº URLHelper çä¾åæ°å»ºä¸ä¸ª WXModulepublic class URLHelperModule extends WXModule&#123; private stat"> -<meta property="og:updated_time" content="2017-04-28T02:36:21.000Z"> -<meta name="twitter:card" content="summary"> -<meta name="twitter:title" content="èªå®ä¹ native API"> -<meta name="twitter:description" content="å¦ä½èªå®ä¹ native APIï¼Weex ç SDK åªæä¾äºé¡µé¢æ¸²æçè½åï¼ä½æ¯ä¸äºå ¶å®æä½ï¼æ¯å¦ç½ç»è¯·æ±ãå¾çå è½½ãéå®åçåè½éè¦ä½ èªå·±å»å®ç°ï¼è¿ä¸ªä¾å讲述äºå¦ä½ç¨åç代ç å»æ©å± Weex çåè½ã å ³äº URLHelper çä¾åæ°å»ºä¸ä¸ª WXModulepublic class URLHelperModule extends WXModule&#123; private stat"> - - <link rel="alternate" href="/atom.xml" title="Weex" type="application/atom+xml"> - - - <link rel="icon" href="//gw.alicdn.com/tps/TB1XNqxPXXXXXcSXVXXXXXXXXXX-64-63.png"> - - - <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css"> - - <link rel="stylesheet" href="/css/style.css"> - <link rel="stylesheet" href="/css/swiper.min.css"> -</head> - -<body id="advanced" class="lang-cn"> - - <script> - window.PAGE_TYPE = "advanced"; - window.ROOT = "/" - </script> - <header id="header"> - <div class="navbar"> - <a id="logo" href="/cn/"> - <img src="//img.alicdn.com/tps/TB1zBLaPXXXXXXeXXXXXXXXXXXX-121-59.svg" /> - </a> - <div class="main-nav"> - <ul class="links"> - <li><a href="/cn/guide">æç¨</a></li> - <li><a href="/cn/references">æå</a></li> - <li class="dropdown"> - <a href="javascript:;">åè</a> - <ul class="dropdown-menu subnav"> - <li> - <a href="/cn/faq.html">FAQ</a> - </li> - <li> - <a href="/cn/releasenote.html">çæ¬è¯´æ</a> - </li> - </ul> - </li> - <li class="dropdown"> - <a href="javascript:;">å·¥å ·åæå¡</a> - <ul class="dropdown-menu subnav"> - <li> - <a href="/cn/playground.html">Playground</a> - </li> - <li> - <a href="/cn/guide/tools/toolkit.html">Weex-toolkit</a> - </li> - <li> - <a href="http://dotwe.org" target="_blank">Code Snippets</a> - </li> - <li> - <a href="https://market.dotwe.org" target="_blank">Market</a> - </li> - </ul> - </li> - </ul> - <ul class="info"> - <li><a href="https://github.com/apache/incubator-weex/" target="_blank"><span class="btn-github iconfont icon-github"></span></a></li> - </ul> - <ul class="tools"> - <li> - <div class="search"> - <form id="search-form" class="search-form"> <!-- æç´¢æ¡ç¸å ³ --> - <input type="text" id="search-input-header" name="q" results="0" class="form-control search-input" autocomplete="off" autocorrect="off"/> - <span class="iconfont icon-search"></span> - </form> - <div class="results-panel"> - </div> -</div> - </li> - <li> - <div class="dropdown select-lang"> - <a href="javascript:;" class="dropdown-toggle"> - Language - <span class="caret"></span> - </a> - <ul class="dropdown-menu pick-lang"> - <li> - <a href="/v-0.10/advanced/cuszomize-native-apis.html" data-lang="en">English</a> - </li> - <li> - <a href="/cn/v-0.10/advanced/cuszomize-native-apis.html" data-lang="zh-cn">ä¸æ</a> - </li> - </ul> - </div> - </li> - <!--<li></li>--> - </ul> - </div> - </div> - <div id="mobile-nav"> - <a id="logo" href="/cn/"> - <img src="//img.alicdn.com/tps/TB1zBLaPXXXXXXeXXXXXXXXXXXX-121-59.svg" /> - </a> - <a class="btn-menu"><span class="iconfont icon-nav"></span></a> - </div> -</header> - - <div id="sidebar" class=""> - <div class="sidebar-menu"> - - <ul class="main-nav"> - <li> - <div class="search"> - <form id="search-form" class="search-form"> <!-- æç´¢æ¡ç¸å ³ --> - <input type="text" id="search-input-sidebar" name="q" results="0" class="form-control search-input" autocomplete="off" autocorrect="off"/> - <span class="iconfont icon-search"></span> - </form> - <div class="results-panel"> - </div> -</div> - </li> - <li> - <a class="" href="/cn/guide"> - æç¨ - </a> - </li> - <li> - <a class="" href="/cn/references"> - æå - </a> - </li> - <li> - <a href="/cn/faq.html"> - FAQ - </a> - </li> - <li> - <p>å·¥å ·åæå¡</p> - <ul class="subnav"> - <li> - <a href="/cn/playground.html">Playground</a> - </li> - <li> - <a href="/cn/guide/tools/devtools.html">Devtools</a> - </li> - <li> - <a href="/cn/guide/tools/weexpack.html">Weexpack</a> - </li> - <li> - <a href="http://dotwe.org" target="_blank">Snippets</a> - </li> - <li> - <a href="https://market.dotwe.org" target="_blank">Market</a> - </li> - </ul> - </li> - <li> - <a href="https://github.com/apache/incubator-weex/" target="_blank"> - GitHub - </a> - </li> - </ul> - - <a class="btn-close-sidebar iconfont icon-close"></a> - </div> -</div> - - <div class="article-wrapper page-layout"> - <div class="doc-nav"> - - - -<div class="summary"> - <h2 class="part-title"> - - é«é¶ç¥è¯ - - </h2> - <ul class="doc-summary"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/index.html" class="sidebar-link ">Weex å·¥ä½åç</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/how-data-binding-works.html" class="sidebar-link ">æ°æ®ç»å®åç</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/create-a-weex-project.html" class="sidebar-link ">å¦ä½å建ä¸ä¸ª Weex 项ç®</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/integrate-to-android.html" class="sidebar-link ">éæå° Android</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/integrate-to-ios.html" class="sidebar-link ">éæå° iOS</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/integrate-to-html5.html" class="sidebar-link ">éæå° web</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/customize-a-native-component.html" class="sidebar-link ">èªå®ä¹ native ç»ä»¶</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/cuszomize-native-apis.html" class="sidebar-link current ">èªå®ä¹ native API</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/extend-to-android.html" class="sidebar-link ">Android æ©å±</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/extend-to-ios.html" class="sidebar-link ">iOS æ©å±</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/extend-to-html5.html" class="sidebar-link ">weex-html5 æ©å±</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/integrate-devtools-to-android.html" class="sidebar-link ">éæ Devtools å° Android</a></h3> - - </li> - - <li> - <h3 class="chapter-title"><a href="/cn/v-0.10/advanced/integrate-devtools-to-ios.html" class="sidebar-link ">éæ Devtools å° iOS</a></h3> - - </li> - - - - </ul> -</div> - </div> - - -<article class="article article-type-advanced"> - <div class="article-entry" itemprop="articleBody"> - <header class="article-header"> - - - <h1 class="article-title" itemprop="name"> - èªå®ä¹ native API - </h1> - - - <time class="article-date" datetime="2017-04-28T02:36:21.000Z">Updated time: 28/04/2017</time> -</header> - <h1 id="å¦ä½èªå®ä¹-native-APIï¼"><a href="#å¦ä½èªå®ä¹-native-APIï¼" class="headerlink" title="å¦ä½èªå®ä¹ native APIï¼"></a>å¦ä½èªå®ä¹ native APIï¼</h1><p>Weex ç SDK åªæä¾äºé¡µé¢æ¸²æçè½åï¼ä½æ¯ä¸äºå ¶å®æä½ï¼æ¯å¦ç½ç»è¯·æ±ãå¾çå è½½ãéå®åçåè½éè¦ä½ èªå·±å»å®ç°ï¼è¿ä¸ªä¾å讲述äºå¦ä½ç¨åç代ç å»æ©å± Weex çåè½ã</p> -<h2 id="å ³äº-URLHelper-çä¾å"><a href="#å ³äº-URLHelper-çä¾å" class="headerlink" title="å ³äº URLHelper çä¾å"></a>å ³äº URLHelper çä¾å</h2><h3 id="æ°å»ºä¸ä¸ª-WXModule"><a href="#æ°å»ºä¸ä¸ª-WXModule" class="headerlink" title="æ°å»ºä¸ä¸ª WXModule"></a>æ°å»ºä¸ä¸ª WXModule</h3><figure class="highlight java"><table><tr><td class="code"><pre><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">URLHelperModule</span> <span class="keyword">extends</span> <span class="title">WXModule</span></span>{</div><div class="line"> <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String WEEX_CATEGORY=<span class="string">"com.taobao.android.intent.category.WEEX"</span>;</div><div class="line"> <span class="meta">@WXModuleAnno</span></div><div class="line"> <span class="function"><span class="keyword">public</span> <span cla ss="keyword">void</span> <span class="title">openURL</span><span class="params">(String url)</span></span>{</div><div class="line"> <span class="keyword">if</span> (TextUtils.isEmpty(url)) {</div><div class="line"> <span class="keyword">return</span>;</div><div class="line"> }</div><div class="line"> StringBuilder builder=<span class="keyword">new</span> StringBuilder(<span class="string">"http:"</span>);</div><div class="line"> builder.append(url);</div><div class="line"> Uri uri = Uri.parse(builder.toString());</div><div class="line"> Intent intent = <span class="keyword">new</span> Intent(Intent.ACTION_VIEW, uri);</div><div class="line"> intent.addCategory(WEEX_CATEGORY);</div><div class="line"> mWXSDKInstance.getContext().startActivity(intent);</div><div class="line"> }</div><div class="line">}</div></pre></td></tr></table></figure> -<p>è¿éè¦æ³¨æ <code>@WXModuleAnno</code> è¿ä¸ªæ³¨è§£ï¼å®è¡¨ç¤ºäºä½ æè¿ä¸ªæ¹æ³æ´é²ç» JavaScriptã</p> -<figure class="highlight java"><table><tr><td class="code"><pre><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">URLHelperModule</span> <span class="keyword">extends</span> <span class="title">WXModule</span></span>{</div><div class="line"></div><div class="line"> <span class="meta">@WXModuleAnno</span></div><div class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">openURL</span><span class="params">(String url,String callbackId)</span></span>{</div><div class="line"> <span class="comment">//...</span></div><div class="line"> <span class="comment">//callback to javascript </span></div><div class="line"> Map<String, Object> result = <span class="keyword">new</span> HashMap<String, Object>();</div><div class="line"> result.put(<span class="string">"ts"</span>, System.currentTime Millis());</div><div class="line"> WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId, result);</div><div class="line"> }</div><div class="line">}</div></pre></td></tr></table></figure> -<h3 id="æmodule注åå°WXSDKEngineï¼"><a href="#æmodule注åå°WXSDKEngineï¼" class="headerlink" title="æmodule注åå°WXSDKEngineï¼"></a>æmodule注åå°WXSDKEngineï¼</h3><figure class="highlight java"><table><tr><td class="code"><pre><div class="line"><span class="keyword">try</span> {</div><div class="line"> WXSDKEngine.registerModule(<span class="string">"myURL"</span>, URLHelperModule.class);</div><div class="line"> <span class="comment">//'myURL' is the name you'll use in javascript</span></div><div class="line"> } <span class="keyword">catch</span> (WXException e) {</div><div class="line"> WXLogUtils.e(e.getMessage());</div><div class="line"> }</div></pre></td></tr></table></figure> -<h3 id="å¨-JavaScript-ä¸ä½¿ç¨-eventModuleï¼"><a href="#å¨-JavaScript-ä¸ä½¿ç¨-eventModuleï¼" class="headerlink" title="å¨ JavaScript ä¸ä½¿ç¨ eventModuleï¼"></a>å¨ JavaScript ä¸ä½¿ç¨ <code>eventModule</code>ï¼</h3><figure class="highlight javascript"><table><tr><td class="code"><pre><div class="line"><span class="keyword">let</span> URLHelper = <span class="built_in">require</span>(<span class="string">'@weex-module/myURL'</span>);<span class="comment">//same as you registered</span></div><div class="line">URLHelper.openURL(<span class="string">"http://www.taobao.com"</span>,<span class="function"><span class="keyword">function</span>(<span class="params">ts</span>)</span>{ </div><div class="line"> <span class="built_in">console</span>.log(<span class="string">"url is open at "</span>+ts);</div><div class="line">});</div></pre></td></tr></table></figure> -<h2 id="ä¸äºæ³¨æäºé¡¹ï¼"><a href="#ä¸äºæ³¨æäºé¡¹ï¼" class="headerlink" title="ä¸äºæ³¨æäºé¡¹ï¼"></a>ä¸äºæ³¨æäºé¡¹ï¼</h2><ol> -<li><p>å®ä¹ä¸ä¸ª components éè¦ç»§æ¿ <code>WXModule</code></p> -</li> -<li><p>ä¸è¦å¿è®°æ·»å <code>@WXModuleAnno</code> 注解ï¼ä¸ç¶ Weex 没æ³è¯å«è¿ä¸ªæ¹æ³</p> -</li> -<li><p>å®ä¹çæ¹æ³å¿ é¡»æ¯ `public ç</p> -</li> -<li><p>module ç±»ä¸å®ä¸è½æ¯å é¨ç±»</p> -</li> -<li><p>ä½ å®ä¹ç components ä¸è½è¢«æ··æ·ï¼ä¸ç¶ä¼æ¾ä¸å°</p> -</li> -<li><p>Module ä¸çæ¹æ³ä¼å¨ UI 线ç¨ä¸è¢«è°ç¨ï¼æ以ä¸å®ä¸è¦åä¸äºèæ¶æä½</p> -</li> -<li><p>Moudle ä¸çæ¹æ³åæ°ç±»åå¯ä»¥ä¸º <code>int</code>ï¼<code>double</code>ï¼<code>float</code>ï¼<code>String</code>ï¼<code>Map</code>ï¼<code>List</code>ï¼ä»¥åå®ç° <code>WXObject</code> æ¥å£çç±»ã</p> -</li> -</ol> - - </div> - -</article> -</div> - - <footer id="footer"> - <div class="row clearfix"> - <div class="dropdown select-lang"> - <a href="javascript:;" class="dropdown-toggle"> - Language - <span class="caret"></span> - </a> - <ul class="dropdown-menu pick-lang"> - <li> - <a href="/v-0.10/advanced/cuszomize-native-apis.html" data-lang="en">English</a> - </li> - <li> - <a href="/cn/v-0.10/advanced/cuszomize-native-apis.html" data-lang="zh-cn">ä¸æ</a> - </li> - </ul> - </div> - </div> - <div class="disclaimer"> - <div><img src="//gw.alicdn.com/tfs/TB1pTBZQFXXXXX9XXXXXXXXXXXX-794-280.png" width="200px" alt="Apache Incubator"></div> - <div><span class="title">Disclaimer:</span> Apache Weex is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.</div> - <br/> - </div> - <hr> - <div class="row"> - <p> <img src="//gw.alicdn.com/tfs/TB1bg8SQFXXXXcHXXXXXXXXXXXX-85-170.png" height="50px" alt="Apache"><span>Copyright(c) 2017 The Apache Software Foundation. Licensed under the </span> <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a></p> - </div> - <div class="row clearfix"> - <div></div> - </div> -</footer> - <div style="display: none;"> - <script src="//s95.cnzz.com/z_stat.php?id=1261496509&web_id=1261496509" language="JavaScript"></script> -</div> - - <script src="/js/reqwest.js"></script> - <script src="/js/common.js"></script> -</body> -</html>