
- Ionic 基礎教程
- Ionic - 首頁
- Ionic - 概述
- Ionic - 環境搭建
- Ionic CSS 元件
- Ionic - 顏色
- Ionic - 內容
- Ionic - 標題
- Ionic - 頁尾
- Ionic - 按鈕
- Ionic - 列表
- Ionic - 卡片
- Ionic - 表單
- Ionic - 開關
- Ionic - 複選框
- Ionic - 單選按鈕
- Ionic - 範圍滑塊
- Ionic - 選擇器
- Ionic - 標籤頁
- Ionic - 網格
- Ionic - 圖示
- Ionic - 內邊距
- Ionic Javascript 元件
- Ionic - JS 動作面板
- Ionic - JS 背景遮罩
- Ionic - JS 內容
- Ionic - JS 表單
- Ionic - JS 事件
- Ionic - JS 標題
- Ionic - JS 頁尾
- Ionic - JS 鍵盤
- Ionic - JS 列表
- Ionic - JS 載入
- Ionic - JS 模態框
- Ionic - JS 導航
- Ionic - JS 氣泡彈出框
- Ionic - JS 彈出框
- Ionic - JS 滾動
- Ionic - JS 側邊選單
- Ionic - JS 滑動框
- Ionic - JS 標籤頁
- Ionic 高階概念
- Ionic - Cordova 整合
- Ionic - AdMob
- Ionic - 相機
- Ionic - Facebook
- Ionic - 應用內瀏覽器
- Ionic - 原生音訊
- Ionic - 地理位置
- Ionic - 媒體
- Ionic - 啟動畫面
- Ionic 有用資源
- Ionic - 快速指南
- Ionic - 有用資源
- Ionic - 討論
Ionic - 選擇器
Ionic 選擇器將建立一個簡單的選單,其中包含使用者可以選擇的選擇項。此選擇選單在不同平臺上的外觀會有所不同,因為其樣式由瀏覽器處理。
使用選擇器
首先,我們將建立一個標籤並新增item-input和item-select類。第二個類將為選擇表單新增額外的樣式,然後我們將在其中新增input-label類,該類將用於為我們的選擇元素新增名稱。我們還將新增select並在其內部新增option。這是一個普通的 HTML5 選擇元素。以下示例顯示了帶有三個選項的 Ionic 選擇器。
<label class = "item item-input item-select"> <div class = "input-label"> Select </div> <select> <option>Option 1</option> <option selected>Option 2</option> <option>Option 3</option> </select> </label>
以上程式碼將生成以下螢幕:

選擇器樣式
以下示例將向您展示如何應用選擇器的樣式。我們正在使用 Ionic 顏色建立包含九個不同樣式選擇元素的列表。由於我們使用的是帶有專案的列表,因此item將是顏色類的字首。
<div class = "list"> <label class = "item item-input item-select item-light"> <div class = "input-label"> Select </div> <select> <option>Option 1</option> <option selected>Option 2</option> <option>Option 3</option> </select> </label> <label class = "item item-input item-select item-stable"> <div class = "input-label"> Select </div> <select> <option>Option 1</option> <option selected>Option 2</option> <option>Option 3</option> </select> </label> <label class = "item item-input item-select item-positive"> <div class = "input-label"> Select </div> <select> <option>Option 1</option> <option selected>Option 2</option> <option>Option 3</option> </select> </label> <label class = "item item-input item-select item-calm"> <div class = "input-label"> Select </div> <select> <option>Option 1</option> <option selected>Option 2</option> <option>Option 3</option> </select> </label> <label class = "item item-input item-select item-balanced"> <div class = "input-label"> Select </div> <select> <option>Option 1</option> <option selected>Option 2</option> <option>Option 3</option> </select> </label> <label class = "item item-input item-select item-energized"> <div class = "input-label"> Select </div> <select> <option>Option 1</option> <option selected>Option 2</option> <option>Option 3</option> </select> </label> <label class = "item item-input item-select item-assertive"> <div class = "input-label"> Select </div> <select> <option>Option 1</option> <option selected>Option 2</option> <option>Option 3</option> </select> </label> <label class = "item item-input item-select item-royal"> <div class = "input-label"> Select </div> <select> <option>Option 1</option> <option selected>Option 2</option> <option>Option 3</option> </select> </label> <label class = "item item-input item-select item-dark"> <div class = "input-label"> Select </div> <select> <option>Option 1</option> <option selected>Option 2</option> <option>Option 3</option> </select> </label> </div>
以上程式碼將生成以下螢幕:

廣告