Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

picker组件 $("#input-id").picker("open") 无法使用 #607

Open
wangyuanhao1 opened this issue Jul 10, 2019 · 1 comment
Open

picker组件 $("#input-id").picker("open") 无法使用 #607

wangyuanhao1 opened this issue Jul 10, 2019 · 1 comment

Comments

@wangyuanhao1
Copy link

wangyuanhao1 commented Jul 10, 2019

错误代码:

  <div class="weui-cell">
        <div class="weui-cell__hd"><label for="date" class="weui-label">手机</label></div>
        <div class="weui-cell__bd">
          <input class="weui-input" id="mobile" type="text" value="">
        </div>
   </div>

   <div>
		<button id="aaa">按钮1</button>
    </div>

<script>
  $(function() {
    FastClick.attach(document.body);
	
	$('#aaa').click(function(){
		$("#mobile").picker("open")
	})
  });

      $("#mobile").picker({
        title: "请选择您的手机",
        cols: [
          {
            textAlign: 'center',
            values: ['iPhone 4', 'iPhone 4S', 'iPhone 5', 'iPhone 5S', 'iPhone 6', 'iPhone 6 Plus', 'iPad 2', 'iPad Retina', 'iPad Air', 'iPad mini', 'iPad mini 2', 'iPad mini 3']
          }
        ],
        onChange: function(p, v, dv) {
          console.log(p, v, dv);
        },
        onClose: function(p, v, d) {
          console.log("close");
        }
      });
</script>

- 运行环境:chrome浏览器

- 重现步骤
点击按钮会直接给picker赋值为数组中的第一个,不会打开picker组件

- 期望结果,实际结果(最好有截图)
期望结果: 打开picker弹板
实际结果: 选中数组中的第一个值

- 如果有报错,请给出报错信息
无报错
@chobitsX
Copy link

chobitsX commented Mar 9, 2021

  • $("#mobile").picker("open")放到setTimeout里即可
  • 代码如下
$('#aaa').click(function(){
    setTimeout(()=>{
         $("#mobile").picker('open')
     },0)
})

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants