Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

server-search-cascader

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

server-search-cascader

vue3版本的级联选择器,支持懒加载和服务端搜索 如果您用的是react,原理一样,看代码修改即可 The cascade selector of vue3 supports lazy loading and server-side search. If you use react, the principle is the same. Just look at the code modification

latest
Source
npmnpm
Version
0.1.5
Version published
Maintainers
1
Created
Source

server-search-cascader

描述

vue3版本的级联选择器,支持懒加载和服务端搜索
如果您用的是react,原理一样,看代码修改即可
The cascade selector of vue3 supports lazy loading and server-side search. If you use react, the principle is the same. Just look at the code modification

安装(install)

yarn add server-search-cascader

使用(use)

main.js

import ServerSearchCascader from "server-search-cascader";
import 'server-search-cascader/lib/server-search-cascader.css'

createApp(App).use(ServerSearchCascader).mount("#app");

app.vue

<template>
  <div class="app">
    <server-search-cascader
      api="/getTeachers"
      v-model="sscValue"
      :field-names="fieldNames"
      @change="onChange"
    />
  </div>
</template>
<script setup>
  import axios from "axios";
  import { ref, onBeforeMount } from "vue";
  const sscValue = ref(null);
  const fieldNames = {
    label: "name",
    value: "id",
    children: "children",
    fullPath: "fullPath",
  };
  const onChange = (item) => {
    console.log("拿到结果", item);
  };
</script>

参数(options)

参数/描述表头
api请求数据的接口
fieldNames别名
change选择事件

后端(server)

需要返回如下的数据结构

{
    "id": "org3",
    "name": "机构3", // 显示名称
    "children": [ // 子节点
        {
            "id": "org3-part1",
            "name": "机构3-部门1",
            "fullPath": [
                {
                    "id": "org3",
                    "name": "机构3"
                },
                {
                    "id": "org3-part1",
                    "name": "机构3-部门1"
                }
            ]
        },
        {
            "id": "org3-part2",
            "name": "机构3-部门2",
            "fullPath": [
                {
                    "id": "org3",
                    "name": "机构3"
                },
                {
                    "id": "org3-part2",
                    "name": "机构3-部门2"
                }
            ]
        }
    ],
    "fullPath": [ // 完整路径
        {
            "id": "org3",
            "name": "机构3"
        }
    ]
}

效果(preview)

preview

FAQs

Package last updated on 06 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts