Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

picker选择器onConfirm无法获取选中的值 #8

Open
zeronehost opened this issue Mar 31, 2020 · 0 comments
Open

picker选择器onConfirm无法获取选中的值 #8

zeronehost opened this issue Mar 31, 2020 · 0 comments

Comments

@zeronehost
Copy link

直接下载代码将dist目录复制到项目中
代码如下:
index.axml

<view>
    <van-cell title="银行" is-link value="{{list[model].label}}" onClick="show"/>
        <van-popup show="{{show}}" position="bottom" onClose="select_close">
        <van-picker title="银行" show-toolbar columns="{{list}}" value-key="label" onCancel="select_cancel" onConfirm="select_confirm"/>
    </van-popup>
</view>

index.js

Page({
  data: {
    list: [{
      brief: "选项一说明",
      label: "选项一",
      value: "1"
    }, {
      brief: "选项二说明",
      label: "选项二",
      value: "2"
    }],
    model: 0,
    show: false
  },
  select_show() {
    this.setData({
      show: true
    });
  },
  select_close() {
    this.setData({
      show: false
    });
  },
  select_cancel() {
    this.select_close();
  },
  select_confirm(e) {
    this.select_close();
    this.setData({
      model: e.detail.index
    });
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant