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阅读 135,301评论 19 139
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 174,942评论 25 709
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 14,191评论 4 61
  • 许多怀揣梦想不断拼搏的人会觉得现在自己生活好辛苦。连我妈妈都经常劝我:钱够用就好,那么拼干嘛?哦,你们不知道,做自...
    bf1c5c66c001阅读 2,701评论 0 0