weex的Debug總結

Q1:模擬器正常顯示,iOS真機不顯示,Xcode輸出如下

 WeexDemo[1424:1061554] [fg100,149,237; <Weex>[info]WXBridgeContext.m:265, No send queue for instance:0, may it has been destroyed so method:fireEvent is ignored [;**
 WeexDemo[1424:1061559] [fg255,0,0; <Weex>[error]WXUtility.m:206, Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.} [;**
WeexDemo[1424:1061549] [fg255,0,0; <Weex>[error]WXUtility.m:206, Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.} [;**

A1:由于nativeCURRENT_IP 與電腦主機號不一致


Q2: 使用repeat時,當數據源的個數沒發生改變時,UI不會刷新?

我在使用repeat的基本方式去實現以下重復組件,發現當我的數據源length沒有發生變化時,我的組件數據是不會被更新的。問題原因未知.

問題代碼:

        <scroller style="width:{{scrollertWidth}}; height:{{deviceHeight}};" class="scroller">
            <div style="flex-direction:row;"> 
                <div repeat="{{children}}" >
                    <div class="subKind" style="width:{{subKindWidth}}; height:{{subKindWidth + 30}}" kindid="{{id}}" onclick="kindClicked">
                        //<img src="{{icon}}" class="img" style="width:{{imgWidth}}; height:{{imgWidth}}; border-radius:{{imgWidth/2.0}}; margin-left:{{paddingLeft}}">
                        <text class="subText" style="width:{{subKindWidth}}">{{name}}</text>
                    </div>
                </div>  
            </div>
        </scroller>

A2:使用了repeat的擴展方法 repeat="{{v in list}}",就可以自動刷新組件中的數據

新的代碼:

        <scroller style="width:{{scrollertWidth}}; height:{{deviceHeight}};" class="scroller">
            <div style="flex-direction:row;"> 
                <div repeat="{{v in children}}" >
                    <div class="subKind" style="width:{{subKindWidth}}; height:{{subKindWidth + 30}}" kindid="{{v.id}}" onclick="kindClicked">
                        //<img src="{{v.icon}}" class="img" style="width:{{imgWidth}}; height:{{imgWidth}}; border-radius:{{imgWidth/2.0}}; margin-left:{{paddingLeft}}">
                        <text class="subText" style="width:{{subKindWidth}}">{{v.name}}</text>
                    </div>
                </div>  
            </div>
        </scroller>

Q3: 使用weex init創建的項目,怎么只啟動一次服務,然后每次修改we文件,只要commond + s然后refresh就可以看到最新的修改效果

A3: 想要達到保存+刷新就能得到效果,可以打開項目中package.json文件,查看里面的scripts腳本指令:

{
  "name": "toomaoweex",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "webpack",
    "dev": "webpack --watch",
    "serve": "serve -p 8080",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-loader": "^6.2.5",
    "babel-plugin-transform-runtime": "^6.15.0",
    "babel-preset-es2015": "^6.14.0",
    "babel-runtime": "^6.11.6",
    "serve": "^1.4.0",
    "webpack": "^1.13.1",
    "weex-html5": "^0.3.0",
    "weex-loader": "^0.3.1"
  }
}

這時候就會發現,scripts提供了4個指令, 其中"dev": "webpack --watch"這個watch參數就表示可以監聽,即當你每次保存的時候,都會自動編譯的,我們只需要執行 npm run dev &即可,&是表示后臺運行,然后再執行npm run serve &開啟服務即可

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • Spring Cloud為開發人員提供了快速構建分布式系統中一些常見模式的工具(例如配置管理,服務發現,斷路器,智...
    卡卡羅2017閱讀 134,923評論 18 139
  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 173,251評論 25 708
  • 發現 關注 消息 iOS 第三方庫、插件、知名博客總結 作者大灰狼的小綿羊哥哥關注 2017.06.26 09:4...
    肇東周閱讀 12,229評論 4 61
  • 許多懷揣夢想不斷拼搏的人會覺得現在自己生活好辛苦。連我媽媽都經常勸我:錢夠用就好,那么拼干嘛?哦,你們不知道,做自...
    bf1c5c66c001閱讀 344評論 0 0