mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-19 09:50:33 +03:00
Merge commit '99f2dfdc0a70a2a6e1e2fe4d1370f8d4b728a3ad' into 975-dropdown-option-slot-overhaul
This commit is contained in:
@@ -17,11 +17,6 @@ module.exports = merge(baseWebpackConfig, {
|
|||||||
minimizer: [
|
minimizer: [
|
||||||
new TerserPlugin({
|
new TerserPlugin({
|
||||||
sourceMap: true,
|
sourceMap: true,
|
||||||
terserOptions: {
|
|
||||||
compress: {
|
|
||||||
drop_console: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<template>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Country</th>
|
||||||
|
</tr>
|
||||||
|
<tr v-for="person in people">
|
||||||
|
<td>{{ person.name }}</td>
|
||||||
|
<td>
|
||||||
|
<v-select
|
||||||
|
:options="options"
|
||||||
|
:value="person.country"
|
||||||
|
@input="country => updateCountry(person, country)"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import countries from '../data/countries';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data: () => ({
|
||||||
|
people: [{name: 'John', country: ''}, {name: 'Jane', country: ''}],
|
||||||
|
}),
|
||||||
|
methods: {
|
||||||
|
updateCountry (person, country) {
|
||||||
|
person.country = country;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
options: () => countries,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
table {
|
||||||
|
display: table;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -114,12 +114,13 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Digging Deeper',
|
title: 'Use Cases',
|
||||||
collapsable: false,
|
collapsable: false,
|
||||||
children: [
|
children: [
|
||||||
['guide/validation', 'Validation'],
|
['guide/validation', 'Validation'],
|
||||||
['guide/vuex', 'Vuex'],
|
['guide/vuex', 'Vuex'],
|
||||||
['guide/ajax', 'AJAX'],
|
['guide/ajax', 'AJAX'],
|
||||||
|
['guide/loops', 'Using in Loops'],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
### Using Vue Select in v-for Loops
|
||||||
|
---
|
||||||
|
|
||||||
|
There may be times that you are including Vue Select within loops of data, such as a table. This can
|
||||||
|
pose some challenges when emitting events from the component, as you won't know which Vue Select
|
||||||
|
instance emitted it. This can make it difficult to wire up with things like Vuex.
|
||||||
|
|
||||||
|
Fortunately, you can solve this problem with an anonymous function. The example below doesn't use
|
||||||
|
Vuex just to keep things succinct, but the same solution would apply. The `@input` is handled
|
||||||
|
with an inline anonymous function, allowing the selected country to be passed to the `updateCountry`
|
||||||
|
method with the `country` and the `person` object.
|
||||||
|
|
||||||
|
<LoopedSelect />
|
||||||
|
|
||||||
|
<<< @/.vuepress/components/LoopedSelect.vue
|
||||||
|
|
||||||
|
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
"private": false,
|
"private": false,
|
||||||
"main": "dist/vue-select.js",
|
"main": "dist/vue-select.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"prepare": "npm run build",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "webpack-dev-server --config build/webpack.dev.conf.js --hot --progress -d",
|
"serve": "webpack-dev-server --config build/webpack.dev.conf.js --hot --progress -d",
|
||||||
"serve:docs": "cd docs && yarn serve",
|
"serve:docs": "cd docs && yarn serve",
|
||||||
|
|||||||
Reference in New Issue
Block a user