<template>
  <div>
    <p>单选：</p>
    <br />
    <tiny-select v-model="value1" :options="options" filterable optimization @change="onChange"></tiny-select>
    <br /><br />
    <p>多选：</p>
    <br />
    <tiny-select
      v-model="value2"
      optimization
      filterable
      multiple
      collapse-tags
      :multiple-limit="5"
      :options="options"
      @change="onChange"
    ></tiny-select>
  </div>
</template>

<script>
import { TinySelect, TinyModal } from '@opentiny/vue'

const buildOptions = () =>
  Array.from({ length: 100000 }).map((item, i) => JSON.parse(`{"value":"选项 ${i}","label":"北京 ${i}"}`))

export default {
  components: {
    TinySelect
  },
  data() {
    return {
      value1: '',
      value2: [],
      options: buildOptions()
    }
  },
  methods: {
    onChange(value) {
      TinyModal.message({
        message: JSON.stringify(value),
        status: 'info'
      })
    }
  }
}
</script>

<style lang="less" scoped>
.tiny-select {
  width: 280px;
}

p {
  font-size: 14px;
  line-height: 1.5;
}
</style>
