New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zan-choose-link-menu

Package Overview
Dependencies
Maintainers
6
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zan-choose-link-menu

选择链接菜单

  • 5.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-56.25%
Maintainers
6
Weekly downloads
 
Created
Source

NPM

下拉选择菜单,主要用来选择不同类型的链接。

使用场景

Design 组件里面很多地方都需要用到选择链接的功能

choose-link-menu-example

代码演示

:::demo 基本用法

import ChooseLinkMenu from 'zan-choose-link-menu';

class Simple extends Component {
  state = {};

  render() {
    return (
      <ChooseLinkMenu
        value={this.state.value}
        onMenuClick={this.onMenuClick}
        onDelete={this.onDelete}
        formatTag={this.formatTag}
        trigger="选择链接"
        menuItems={[
          {
            title: '地球',
            key: 'earth'
          },
          {
            title: '火星',
            key: 'mars'
          }
        ]}
      />
    );
  }

  onMenuClick = (evt, key) => {
    return this.setState({
      value: {
        type: key,
        content: key === 'earth' ? '地球欢迎你' : '火星欢迎你'
      }
    });
  };

  onDelete = () => {
    this.setState({
      value: null
    });
  };

  formatTag(value) {
    return {
      type: value.type === 'earth' ? '地球' : '火星',
      title: value.content,
      url: value.type === 'earth' ? 'https://youzan.com' : 'https://bbs.youzan.com'
    };
  }
}

ReactDOM.render(<Simple />, mountNode);

:::

API

参数说明类型默认值备选值
value当前选中的值any
menuItems下拉菜单数组,每一项都是一个对象,包含 title, key 两个字段{ title: node, key: string }[][]
onMenuClick菜单点击回调函数(event, key) => void
onDelete删除选中值时的回调函数event => void
trigger没有值选中时的触发节点node
formatTag选中值之后用于格式化显示的函数value => { type: string, title: node, url: string }
isEmptyValue判断当前值是否是空的value => boolvalue => !value
menuHideDelay菜单关闭延迟,毫秒number250
menuShowDelay菜单打开延迟,毫秒number150
className自定义额外类名string''''

FAQs

Package last updated on 03 Aug 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc