Q1:模擬器正常顯示,iOS真機(jī)不顯示,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:由于native中CURRENT_IP 與電腦主機(jī)號不一致
Q2: 使用repeat時,當(dāng)數(shù)據(jù)源的個數(shù)沒發(fā)生改變時,UI不會刷新?
我在使用repeat的基本方式去實現(xiàn)以下重復(fù)組件,發(fā)現(xiàn)當(dāng)我的數(shù)據(jù)源length沒有發(fā)生變化時,我的組件數(shù)據(jù)是不會被更新的。問題原因未知.
問題代碼:
<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的擴(kuò)展方法 repeat="{{v in list}}",就可以自動刷新組件中的數(shù)據(jù)
新的代碼:
<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創(chuàng)建的項目,怎么只啟動一次服務(wù),然后每次修改we文件,只要commond + s然后refresh就可以看到最新的修改效果
A3: 想要達(dá)到保存+刷新就能得到效果,可以打開項目中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"
}
}
這時候就會發(fā)現(xiàn),scripts提供了4個指令, 其中"dev": "webpack --watch"這個watch參數(shù)就表示可以監(jiān)聽,即當(dāng)你每次保存的時候,都會自動編譯的,我們只需要執(zhí)行 npm run dev &即可,&是表示后臺運行,然后再執(zhí)行npm run serve &開啟服務(wù)即可