zoukankan      html  css  js  c++  java
  • elementUI-select 远程搜索

    设置三个远程属性,调用模糊接口<br><template>

      <ui-select
        v-model="dataId"
        filterable
        remote
        reserve-keyword
        placeholder="请输入人名进行搜索"
        :remote-method="userSearch"
        :loading="userSearchLoading"
        @change="userSelected">
        <ui-option
          v-for="item in userResult"
          :key="item.id"
          :label="item.userName"
          :value="item.id">
        </ui-option>
      </ui-select>
    </template>
     
    <script>
      import api from '@/api/user'
     
      export default {
        components: {},
        // 父组件构建user对象传入(内容id和userName)
        props: ['user'],
        methods: {
          userSearch(query) {
            if (query !== '') {
              this.userSearchLoading = true
              api.pageQueryOnJobUsers({
                userName: query
              })
              .then(r => {
                this.userResult = r.data.data.list
                this.userSearchLoading = false
              })
              .catch(r => {
                this.userSearchLoading = false
              })
            }
          },
          // 触发selectedUserId绑定的事件
          userSelected(value) {
            this.$emit('selectedUserId', value)
          }
        },
        mounted() {
        },
        data() {
          return {
            userSearchLoading: false,
            // 调用父组件的至进行填充(如有)
            userResult: this.user ? [this.user] : null,
            dataId: this.user ? this.user.id : null
          }
        }
      }
    </script>
     
    <!-- Add "scoped" attribute to limit CSS to this component only -->
    <style scoped lang="scss">
     
    </style>
  • 相关阅读:
    kibana 版本kibana-4.3.1 修改地图
    安装GeoIP数据库
    获取nginx ip地理信息
    数据接口示例
    elasticsearch 搜索不支持单词的部分进行匹配
    5,扩展方案
    (?m)使用实例
    Oracle 唯一主键引发的行锁
    场景2 nginx 错误日志格式:
    POSTGRESQL NO TABLE
  • 原文地址:https://www.cnblogs.com/soonK/p/9518165.html
Copyright © 2011-2022 走看看