mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-04 06:32:23 +03:00
297 lines
13 KiB
HTML
297 lines
13 KiB
HTML
|
|
<!DOCTYPE HTML>
|
|
<html lang="" >
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
|
<title>Introduction · GitBook</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="gitbook/gitbook-plugin-fontsettings/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">
|
|
|
|
|
|
|
|
|
|
</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 active" data-level="1.1" data-path="./">
|
|
|
|
<a href="./">
|
|
|
|
|
|
Introduction
|
|
|
|
</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="." >Introduction</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">
|
|
|
|
<h1 id="vue-select------">vue-select <a href="https://travis-ci.org/sagalbot/vue-select" target="_blank"><img src="https://travis-ci.org/sagalbot/vue-select.svg?branch=master" alt="Build Status"></a> <a href="https://lima.codeclimate.com/github/sagalbot/vue-select" target="_blank"><img src="https://img.shields.io/codeclimate/github/sagalbot/vue-select.svg?style=flat-square" alt="Code Score"></a> <a href="https://codeclimate.com/github/sagalbot/vue-select" target="_blank"><img src="https://img.shields.io/codeclimate/coverage/github/sagalbot/vue-select.svg?style=flat-square" alt="Code Coverage"></a> <a href="https://gemnasium.com/github.com/sagalbot/vue-select" target="_blank"><img src="https://img.shields.io/gemnasium/sagalbot/vue-select.svg?style=flat-square" alt="No Dependencies"></a> <img src="https://img.shields.io/github/license/sagalbot/vue-select.svg?style=flat-square" alt="MIT License"> <img src="https://img.shields.io/github/release/sagalbot/vue-select.svg?style=flat-square" alt="Current Release"></h1>
|
|
<blockquote>
|
|
<p>A native Vue.js select component that provides similar functionality to Select2 without the overhead of jQuery.</p>
|
|
</blockquote>
|
|
<h4 id="features">Features</h4>
|
|
<ul>
|
|
<li>AJAX Support</li>
|
|
<li>Tagging</li>
|
|
<li>List Filtering/Searching</li>
|
|
<li>Supports Vuex</li>
|
|
<li>Select Single/Multiple Options</li>
|
|
<li>Tested with Bootstrap 3/4, Bulma, Foundation</li>
|
|
<li>+95% Test Coverage</li>
|
|
<li>~33kb minified with CSS</li>
|
|
<li>Zero dependencies</li>
|
|
</ul>
|
|
<h2 id="documentation">Documentation</h2>
|
|
<ul>
|
|
<li><strong><a href="http://sagalbot.github.io/vue-select/" target="_blank">Demo & Docs</a></strong></li>
|
|
<li><strong><a href="http://jsbin.com/saxaru/8/edit?html,js,output" target="_blank">Example on JSBin</a></strong></li>
|
|
<li><strong><a href="http://codepen.io/sagalbot/pen/NpwrQO" target="_blank">CodePen Template</a></strong></li>
|
|
<li><strong><a href="https://trello.com/b/vWvITNzS/vue-select" target="_blank">Trello Roadmap</a></strong></li>
|
|
</ul>
|
|
<h2 id="install">Install</h2>
|
|
<h6 id="vue-compatibility">Vue Compatibility</h6>
|
|
<ul>
|
|
<li><code>vue ~2.0</code> use <code>vue-select ~2.0</code></li>
|
|
<li><code>vue ~1.0</code> use <code>vue-select ~1.0</code></li>
|
|
</ul>
|
|
<h4 id="npm">NPM</h4>
|
|
<p>Install the package. <em>You should install <code>vue-select@1.3.3</code> for use with vue <code>~1.0</code>.</em></p>
|
|
<pre><code class="lang-bash">$ npm install vue-select
|
|
</code></pre>
|
|
<p>Register the component</p>
|
|
<pre><code class="lang-js"><span class="hljs-keyword">import</span> Vue <span class="hljs-keyword">from</span> <span class="hljs-string">'vue'</span>
|
|
<span class="hljs-keyword">import</span> vSelect <span class="hljs-keyword">from</span> <span class="hljs-string">'vue-select'</span>
|
|
Vue.component(<span class="hljs-string">'v-select'</span>, vSelect)
|
|
</code></pre>
|
|
<p>You may now use the component in your markup</p>
|
|
<pre><code class="lang-html"><span class="hljs-tag"><<span class="hljs-name">v-select</span> <span class="hljs-attr">v-model</span>=<span class="hljs-string">"selected"</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>
|
|
<h4 id="cdn">CDN</h4>
|
|
<p>Just include <code>vue</code> & <code>vue-select.js</code> - I recommend using <a href="https://unpkg.com/#/" target="_blank">unpkg</a>.</p>
|
|
<pre><code class="lang-html"><span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://unpkg.com/vue@latest"</span>></span><span class="undefined"></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span>
|
|
<span class="hljs-comment"><!-- use the latest release --></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://unpkg.com/vue-select@latest"</span>></span><span class="undefined"></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span>
|
|
<span class="hljs-comment"><!-- or point to a specific release --></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://unpkg.com/vue-select@1.3.3"</span>></span><span class="undefined"></span><span class="hljs-tag"></<span class="hljs-name">script</span>></span>
|
|
</code></pre>
|
|
<p>Then register the component in your javascript:</p>
|
|
<pre><code class="lang-js">Vue.component(<span class="hljs-string">'v-select'</span>, VueSelect.VueSelect);
|
|
</code></pre>
|
|
<p>You may now use the component in your markup</p>
|
|
<pre><code class="lang-html"><span class="hljs-tag"><<span class="hljs-name">v-select</span> <span class="hljs-attr">v-model</span>=<span class="hljs-string">"selected"</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>Here's an <a href="http://jsbin.com/saxaru/5/edit?html,js,output" target="_blank">example on JSBin</a>.</p>
|
|
<h2 id="basic-usage">Basic Usage</h2>
|
|
<h4 id="syncing-a-selected-value">Syncing a Selected Value</h4>
|
|
<p>The most common use case for <code>vue-select</code> is to have the chosen value synced with a parent component. <code>vue-select</code> takes advantage of the <code>v-model</code> syntax to sync values with a parent.</p>
|
|
<pre><code class="lang-html"><span class="hljs-tag"><<span class="hljs-name">v-select</span> <span class="hljs-attr">v-model</span>=<span class="hljs-string">"selected"</span>></span><span class="hljs-tag"></<span class="hljs-name">v-select</span>></span>
|
|
</code></pre>
|
|
<pre><code class="lang-js"><span class="hljs-keyword">new</span> Vue({
|
|
data: {
|
|
selected: <span class="hljs-literal">null</span>
|
|
}
|
|
})
|
|
</code></pre>
|
|
<h4 id="setting-options">Setting Options</h4>
|
|
<p><code>vue-select</code> accepts arrays of strings and 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 'label' 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="for-more-information-please-visit-the-vue-select-documentation">For more information, please visit the <a href="https://sagalbot.github.io/vue-select" target="_blank">vue-select documentation.</a></h3>
|
|
|
|
|
|
</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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<script>
|
|
var gitbook = gitbook || [];
|
|
gitbook.push(function() {
|
|
gitbook.page.hasChanged({"page":{"title":"Introduction","level":"1.1","depth":1,"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"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}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"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"}},"file":{"path":"README.md","mtime":"2017-08-16T19:18:27.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2017-09-03T18:24:52.161Z"},"basePath":".","book":{"language":""}});
|
|
});
|
|
</script>
|
|
</div>
|
|
|
|
|
|
<script src="gitbook/gitbook.js"></script>
|
|
<script src="gitbook/theme.js"></script>
|
|
|
|
|
|
<script src="gitbook/gitbook-plugin-livereload/plugin.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>
|
|
|
|
|
|
|
|
<script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|
|
|