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:由于native
中CURRENT_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 &
开启服务即可
网友评论