Git Product home page Git Product logo

multiple-level-picker's Introduction

版本

當前版本為 v2,後續描述皆以此版本為主

安裝方式

分為兩個主要檔案,一支 css 以及一支 js

  <link href="${your_path}/multiple-level-picker.v2.css" rel="stylesheet" />
  <script src="${your_path}/multipleLevelPicker.v2.js"></script>

使用方式

const config = {
  source: 'http://test.iwowpao.com/api/industryclass.php',
  prefix: 'industry',
  limit: 3,
  title: '產品類型選單',
  rootTab: '全部產品',
  limitText: '已選擇:',
}
const picker = new MultipleLevelPicker(config);

此範例資料來源為 industry api ,source 為必要設定 以下為所有設定

設定

名稱 資料類型 預設值 功能說明
prefix String 用於指定此選單內指定 id 屬性的前綴
limit Number 1 限制選單可選取數量
source String null 指定選單的資料來源 api,必填
selectLowest Boolean false 設定是否僅能選擇最底層的選項
acceptLevel Number 99 設定顯示層級
lang String 1 指定 api 拉取資料語言
text Object 設定顯示文字,細節設定見 text 表格
chosen Object {} 設定預設已選項目,格式範例見下
zIndex Number 99999 設定選單z-index層級

text 設定範例與內容

const text = {
  title: '產品選單',
  submitBtn: '確認送出',
  canelBtn: '取消',
}
名稱 資料類型 預設值 欄位說明
title String Menu 選單標題
limit String Selected 已選提示顯示
rootTab String All 跟目錄頁籤文字
submitBtn String Submit 送出按鈕文字
cancelBtn String Cancel 取消按鈕文字

chosen 格式範例

const obj ={
  '010300000000': '動物飼料',
  '010101000000': '農用溫室',
  '020102000000': '親子裝'
};

Callbacks

此套件目前提供以下回傳,使用範例與回傳時機說明如下:

picker.on('submit', (res) => {console.log(res)});
名稱 作用時機 回傳資料
update 當資料異動時 當前選擇的資料
submit 當按下送出按鍵時 當前選擇的資料
cancel 當按下取消按鍵時 本來已選擇的資料

Methods

使用範例

picker.remove(`${id}`);
名稱 作用 參數
show() 顯示選單
hide() 隱藏選單
add(i, v) 增加資料 i: 增加資料的id
v: 增加資料的文字名稱
remove(i) 刪除資料 i: 增加資料的id

multiple-level-picker's People

Contributors

lobster0429 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.