weex icon indicating copy to clipboard operation
weex copied to clipboard

picker在手机上为啥不能用啊

Open The-Pursuit-of-Happyness opened this issue 9 years ago • 24 comments

本来说,想试试这个全新的框架,可是引入picker后,界面压根不能正常渲染 image

能够出来的是这个项目的例子,但是数据选择器,时间选择器,都不能正常的渲染出来,那几个按钮点了也是渲染错误,android手机上测试的 求大神指点迷津!!!!!

@The-Pursuit-of-Happyness 运行这个例子的log你能贴出来么,这样可以加快我们排查的进度

alext1981 avatar Jan 16 '17 05:01 alext1981

这个是chrome浏览器上运行时的结果,文档上有说h5目前不支持,但是手机端运行的也没法查看log啊, image

image 连上android Studio后log里面一直这么刷

你好,麻烦提供你的Android机型信息和操作系统版本信息。另外点击各个按钮后Logcat的输出内容可以的话也麻烦提供一下

misakuo avatar Jan 16 '17 05:01 misakuo

手机版本信息: image

三个选择按钮分别点击报的错误 image

界面顶部都会显示: render error :null

android studio的log能提供一下么

misakuo avatar Jan 16 '17 06:01 misakuo

额,上面不显示的,一直刷那个上面的log image

请提供一下dialog.we文件的内容

misakuo avatar Jan 16 '17 08:01 misakuo

代码放进去不行,会被浏览器解析一部分,会变成下面这个样子,其实代码就是picker-demo.we的源码,只是稍稍改动了一点点

<template>
    <scroller>
        <wxc-panel title="picker module" type="primary">
            <text style="margin-bottom: 20px;">pick value: {{value}}</text>
            <wxc-button type="primary" onclick="{{pick}}" value="single pick" style="margin-bottom: 20px;"></wxc-button>
            <wxc-button type="primary" onclick="{{pickDate}}" value="pickDate" style="margin-bottom: 20px;"></wxc-button>
            <wxc-button type="primary" onclick="{{pickTime}}" value="pickTime"></wxc-button>
        </wxc-panel>

        <wxc-panel title="input component" type="primary">
            <text>onchange: {{txtChange}}</text>
            <input
                    type="date"
                    placeholder="select date"
                    class="input"
                    autofocus="false"
                    value=""
                    onchange="onchange"
                    max = "2029-11-28"
                    min = "2015-11-28"
            />
            <input
                    type="time"
                    placeholder="select time"
                    class="input"
                    autofocus="false"
                    value=""
                    onchange="onchange"
            />
        </wxc-panel>
    </scroller>
</template>

<style>
    .input {
        font-size: 60px;
        height: 80px;
        width: 400px;
    }
</style>

<script>
    require('weex-components');
    var picker
__weex_define__('@weex-temp/api', function(__weex_require__) {
  picker = __weex_require__('@weex-module/picker')
});
    module.exports = {
        data: {
            value: '',
            index: 0,
            txtChange: ''
        },
        methods: {
            pick: function() {
                //var picker = require('@weex-module/picker');
                var items = new Array("Saab","Volvo","BMW");
                var self = this;
                picker.pick({
                    'items':items,
                    'index':self.index
                },function (ret) {
                    var result = ret.result;
                    if(result == 'success')
                    {
                        self.value = items[ret.data];
                        self.index = ret.data;
                    }
                });

            },
            pickDate: function() {
                //var picker = require('@weex-module/picker');
                var self = this;
                picker.pickDate({
                    'value':'2016-11-28',
                    'max':'2029-11-28',
                    'min':'2015-11-28'
                },function (ret) {
                    var result = ret.result;
                    if(result == 'success')
                    {
                        self.value = ret.data;
                    }
                });
            },
            pickTime: function() {
                //var picker = require('@weex-module/picker');
                var self = this;
                picker.pickTime({
                    'value':'19:24'
                },function (ret) {
                    var result = ret.result;
                    if(result == 'success')
                    {
                        self.value = ret.data;
                    }
                });
            },
            onchange: function(event) {
                this.txtChange = event.value;
                console.log('onchange', event.value);
            }
        }
    }
</script>

我编辑了一下,是上面这样的内容么?

misakuo avatar Jan 16 '17 08:01 misakuo

其实就是picker-demo.we的源码,就把@click改成了onclick ,其他好像几乎没有改变

playground里的picker-demo可否正确运行?

misakuo avatar Jan 16 '17 08:01 misakuo

不能,只有input选择日期的能正确,其他都不行

麻烦确认一下使用iOS的playground能否正确运行你的demo

misakuo avatar Jan 17 '17 07:01 misakuo

@misakuo @The-Pursuit-of-Happyness ios上The-Pursuit-of-Happyness提供的demo是可以运行的

kfeagle avatar Jan 19 '17 01:01 kfeagle

那为啥Android上不能运行? ;) ;)

需要确认几个问题:

  1. we文件逻辑是否有问题,上面js报的错误是picker.pick is not a function,表明picker模块是存在的,不过调用的函数未被定义,你可以先把picker和picker.pick在console里输出一下看看具体指向什么对象,或者使用DevTools断点调试。
  2. 如果可以在Android端 Weex SDK 内断点,确认@WXModuleAnno修饰的几个方法是否有被调用到,如果调用异常,麻烦提供Logcat内的异常信息。
  3. Playground内Picker示例中 select date 和 select time 两个例子能否正确运行

misakuo avatar Jan 19 '17 03:01 misakuo

1、picker.pick 这个函数不是我定义的,picker输出是一个对象,picker.pick输出是undefined 2、@WXModule的其他几个模块是可以用的,比如说动画,toast等都是可用的 3、playground内的Picker示例中, 在谷歌浏览器中 select data 和select time 是可以正常运行的,但是android端就会被渲染成普通文本输入框。 4、非常想请教一下,如果要实现点击输入框上传图片或文件,该如何实现

非常感谢你的耐心解答,祝愿你们的weex框架越来越好用!!!!