参考@官网文档

代码:

<template>
  <div>
    <van-field readonly="" is-link @click="show = true" v-model="inputval" name="测试单选" label="测试单选" />
    <van-action-sheet v-model="show" :actions="actions" @select="onSelect" />
  </div>
</template>
<script>
  export default {
    data() {
      return {
        inputval: '',
        show: false,
        actions: [{
          name: '选项一'
        }, {
          name: '选项二'
        }, {
          name: '选项三'
        }],
      };
    },
    methods: {
      onSelect(item) {
        // 默认情况下点击选项时不会自动收起
        // 可以通过 close-on-click-action 属性开启自动收起
        this.show = false;
        this.inputval = item.name
      },
    },
  };
</script>
<style>
</style>
View Code

相关文章:

  • 2021-10-29
  • 2022-12-23
  • 2021-12-12
  • 2022-01-10
  • 2021-05-13
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
猜你喜欢
  • 2021-04-18
  • 2021-05-22
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2021-04-18
相关资源
相似解决方案