mirror of
https://github.com/tenrok/vue-select.git
synced 2026-05-17 02:29:37 +03:00
486 lines
14 KiB
HTML
486 lines
14 KiB
HTML
|
|
<!DOCTYPE HTML>
|
|
<html lang="" >
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
|
<title>Dropdown Options · vue-select</title>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
<meta name="description" content="">
|
|
<meta name="generator" content="GitBook 3.2.3">
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../gitbook/style.css">
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../styles/website.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<meta name="HandheldFriendly" content="true"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
|
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
|
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
|
|
|
|
|
<link rel="next" href="Options.html" />
|
|
|
|
|
|
<link rel="prev" href="../Install.html" />
|
|
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<div class="book">
|
|
<div class="book-summary">
|
|
|
|
|
|
<div id="book-search-input" role="search">
|
|
<input type="text" placeholder="Type to search" />
|
|
</div>
|
|
|
|
|
|
<nav role="navigation">
|
|
|
|
|
|
|
|
<ul class="summary">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="chapter " data-level="1.1" data-path="../">
|
|
|
|
<a href="../">
|
|
|
|
|
|
Introduction
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.2" >
|
|
|
|
<span>
|
|
|
|
|
|
Getting Started
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.3" data-path="../Install.html">
|
|
|
|
<a href="../Install.html">
|
|
|
|
|
|
Installation
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter active" data-level="1.4" data-path="Options.html">
|
|
|
|
<a href="Options.html">
|
|
|
|
|
|
Dropdown Options
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<ul class="articles">
|
|
|
|
|
|
<li class="chapter " data-level="1.4.1" data-path="Options.html">
|
|
|
|
<a href="Options.html#labels">
|
|
|
|
|
|
Option Labels
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.4.2" data-path="Options.html">
|
|
|
|
<a href="Options.html#null">
|
|
|
|
|
|
Null Options
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.5" data-path="Values.html">
|
|
|
|
<a href="Values.html#values">
|
|
|
|
|
|
Selecting Values
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<ul class="articles">
|
|
|
|
|
|
<li class="chapter " data-level="1.5.1" data-path="Values.html">
|
|
|
|
<a href="Values.html#single">
|
|
|
|
|
|
Single
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.5.2" data-path="Values.html">
|
|
|
|
<a href="Values.html#multiple">
|
|
|
|
|
|
Multiple
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.5.3" data-path="Values.html">
|
|
|
|
<a href="Values.html#tagging">
|
|
|
|
|
|
Tagging
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.6" data-path="Localization.html">
|
|
|
|
<a href="Localization.html">
|
|
|
|
|
|
Localization
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.7" >
|
|
|
|
<span>
|
|
|
|
|
|
Digging Deeper
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.8" data-path="../Advanced/Templating.html">
|
|
|
|
<a href="../Advanced/Templating.html">
|
|
|
|
|
|
Templating
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.9" data-path="../Advanced/Vuex.html">
|
|
|
|
<a href="../Advanced/Vuex.html">
|
|
|
|
|
|
Vuex
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.10" data-path="../Advanced/Ajax.html">
|
|
|
|
<a href="../Advanced/Ajax.html">
|
|
|
|
|
|
AJAX
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.11" data-path="../Examples.html">
|
|
|
|
<a href="../Examples.html">
|
|
|
|
|
|
Examples
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.12" >
|
|
|
|
<span>
|
|
|
|
|
|
API
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.13" data-path="../Api/Props.html">
|
|
|
|
<a href="../Api/Props.html">
|
|
|
|
|
|
Props
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
<li class="divider"></li>
|
|
|
|
<li>
|
|
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
|
|
Published with GitBook
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
|
|
|
|
</nav>
|
|
|
|
|
|
</div>
|
|
|
|
<div class="book-body">
|
|
|
|
<div class="body-inner">
|
|
|
|
|
|
|
|
<div class="book-header" role="navigation">
|
|
|
|
|
|
<!-- Title -->
|
|
<h1>
|
|
<i class="fa fa-circle-o-notch fa-spin"></i>
|
|
<a href=".." >Dropdown Options</a>
|
|
</h1>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="page-wrapper" tabindex="-1" role="main">
|
|
<div class="page-inner">
|
|
|
|
<div id="book-search-results">
|
|
<div class="search-noresults">
|
|
|
|
<section class="normal markdown-section">
|
|
|
|
<h2 id="options">Dropdown Options </h2>
|
|
<p><code>vue-select</code> accepts arrays of strings or objects to use as options through the <code>options</code> prop:</p>
|
|
<pre><code class="lang-html"><span class="hljs-tag"><<span class="hljs-name">v-select</span> <span class="hljs-attr">:options</span>=<span class="hljs-string">"['foo','bar']"</span>></span><span class="hljs-tag"></<span class="hljs-name">v-select</span>></span>
|
|
</code></pre>
|
|
<p>When provided an array of objects, <code>vue-select</code> will display a single value of the object. By default, <code>vue-select</code> will look for a key named <code>label</code> on the object to use as display text.</p>
|
|
<pre><code class="lang-html"><span class="hljs-tag"><<span class="hljs-name">v-select</span> <span class="hljs-attr">:options</span>=<span class="hljs-string">"[{label: 'foo', value: 'Foo'}]"</span>></span><span class="hljs-tag"></<span class="hljs-name">v-select</span>></span>
|
|
</code></pre>
|
|
<h3 id="labels">Option Labels </h3>
|
|
<p>When the <code>options</code> array contains objects, <code>vue-select</code> looks for the <code>label</code> key to display by default. You can set your own label to match your source data using the <code>label</code> prop.</p>
|
|
<p>For example, consider an object with <code>countryCode</code> and <code>countryName</code> properties:</p>
|
|
<pre><code class="lang-json">{
|
|
countryCode: <span class="hljs-string">"CA"</span>,
|
|
countryName: <span class="hljs-string">"Canada"</span>
|
|
}
|
|
</code></pre>
|
|
<p>If you wanted to display <code>Canada</code> in the dropdown, you'd use the <code>countryName</code> key:</p>
|
|
<pre><code class="lang-html"><span class="hljs-tag"><<span class="hljs-name">v-select</span> <span class="hljs-attr">label</span>=<span class="hljs-string">"countryName"</span> <span class="hljs-attr">:options</span>=<span class="hljs-string">"countries"</span>></span><span class="hljs-tag"></<span class="hljs-name">v-select</span>></span>
|
|
</code></pre>
|
|
<p></p><p data-height="500" data-theme-id="32252" data-slug-hash="aEjLPB" data-default-tab="result" data-user="sagalbot" class="codepen">See the Pen <a href="http://codepen.io/sagalbot/pen/aEjLPB/" target="_blank"></a> by sagalbot (<a href="http://codepen.io/sagalbot" target="_blank">@sagalbot</a>) on <a href="http://codepen.io" target="_blank">CodePen</a>.</p><p></p>
|
|
<h3 id="emptyOptions">Null / Empty Options </h3>
|
|
<p><code>vue-select</code> requires the <code>option</code> property to be an <code>array</code>. If you are using Vue in development mode, you will get warnings attempting to pass anything other than an <code>array</code> to the <code>options</code> prop. If you need a <code>null</code>/<code>empty</code> value, use an empty array <code>[]</code>.</p>
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
<div class="search-results">
|
|
<div class="has-results">
|
|
|
|
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
|
<ul class="search-results-list"></ul>
|
|
|
|
</div>
|
|
<div class="no-results">
|
|
|
|
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a href="../Install.html" class="navigation navigation-prev " aria-label="Previous page: Installation">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
|
|
<a href="Options.html#labels" class="navigation navigation-next " aria-label="Next page: Option Labels">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<script>
|
|
var gitbook = gitbook || [];
|
|
gitbook.push(function() {
|
|
gitbook.page.hasChanged({"page":{"title":"Dropdown Options","level":"1.4","depth":1,"next":{"title":"Option Labels","level":"1.4.1","depth":2,"anchor":"#labels","path":"Basics/Options.md","ref":"Basics/Options.md#labels","articles":[]},"previous":{"title":"Installation","level":"1.3","depth":1,"path":"Install.md","ref":"Install.md","articles":[]},"dir":"ltr"},"config":{"plugins":["edit-link","-fontsettings","codepen","include-csv"],"root":"./docs/gitbook","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"include-csv":{},"github":{"url":"https://github.com/sagalbot/vue-select/"},"search":{},"codepen":{"theme":32252},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"highlight":{},"sharing":{"facebook":false,"twitter":false,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"edit-link":{"label":"Edit This Page","base":"https://github.com/sagalbot/vue-select/edit/gitbook/docs/gitbook"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"vue-select","links":{"sharing":{"facebook":false,"twitter":false}},"gitbook":">3.0.0"},"file":{"path":"Basics/Options.md","mtime":"2018-01-15T03:46:32.219Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-01-15T23:01:42.518Z"},"basePath":"..","book":{"language":""}});
|
|
});
|
|
</script>
|
|
</div>
|
|
|
|
|
|
<script src="../gitbook/gitbook.js"></script>
|
|
<script src="../gitbook/theme.js"></script>
|
|
|
|
|
|
<script src="../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
|
|
|
|
|
|
|
|
<script src="../gitbook/gitbook-plugin-codepen/embed-codepen.js"></script>
|
|
|
|
|
|
|
|
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
|
|
|
|
|
|
|
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
|
|
|
|
|
|
|
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
|
|
|
|
|
|
|
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
|
|
|
|
|
|
|
<script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|
|
|