mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
remove global component references from docs (#862)
This commit is contained in:
@@ -1,24 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<v-select
|
<v-select
|
||||||
:options="['Canada', 'United States']"
|
:options="['Canada', 'United States']"
|
||||||
:components="{Deselect}"
|
:components="{Deselect}"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Vue from 'vue';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
computed: {
|
data: () => ({
|
||||||
Deselect () {
|
Deselect: {
|
||||||
return Vue.component('Deselect', {
|
render: createElement => createElement('button', 'Clear'),
|
||||||
render (createElement) {
|
|
||||||
return createElement('button', 'Clear');
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
},
|
}),
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,25 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<custom-select :options="['Vue.js', 'React', 'Angular']" />
|
<v-select
|
||||||
|
:options="['Vue.js', 'React', 'Angular']"
|
||||||
|
:components="components"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Vue from 'vue';
|
export default {
|
||||||
import vSelect from '../../../src/components/Select';
|
data: () => ({
|
||||||
|
components: {
|
||||||
const components = {
|
Deselect: {
|
||||||
Deselect: Vue.component('Deselect', {
|
render: createElement => createElement('button', '❌'),
|
||||||
render: (createElement) => createElement('button', '❌'),
|
},
|
||||||
}),
|
OpenIndicator: {
|
||||||
OpenIndicator: Vue.component('OpenIndicator', {
|
render: createElement => createElement('span', '🔽'),
|
||||||
render: (createElement) => createElement('span', '🔽'),
|
},
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
const mySelect = {...vSelect};
|
|
||||||
|
|
||||||
mySelect.props.components.default = () => components;
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {'custom-select': mySelect}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,29 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<v-select
|
<v-select
|
||||||
multiple
|
multiple
|
||||||
v-model="selected"
|
v-model="selected"
|
||||||
:options="['Canada', 'United States']"
|
:options="['Canada', 'United States']"
|
||||||
:components="{OpenIndicator}"
|
:components="{OpenIndicator}"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Vue from 'vue';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data: () => ({
|
data: () => ({
|
||||||
selected: ['Canada']
|
selected: ['Canada'],
|
||||||
}),
|
OpenIndicator: {
|
||||||
computed: {
|
render: createElement => createElement('span', {class: {'toggle': true}}),
|
||||||
OpenIndicator () {
|
|
||||||
return Vue.component('OpenIndicator', {
|
|
||||||
render (createElement) {
|
|
||||||
return createElement('i', '🤘🏻');
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
},
|
}),
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+24
-33
@@ -19,15 +19,13 @@ a simple `<button>Clear</button>` instead.
|
|||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
computed: {
|
export default {
|
||||||
Deselect() {
|
data: () => ({
|
||||||
return Vue.component('Deselect', {
|
Deselect: {
|
||||||
render (createElement) {
|
render: createElement => createElement('button', 'Clear'),
|
||||||
return createElement('button', 'Clear')
|
},
|
||||||
}
|
}),
|
||||||
})
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<ClearButtonOverride />
|
<ClearButtonOverride />
|
||||||
@@ -45,20 +43,19 @@ based on whether the dropdown is open or closed.
|
|||||||
<v-select :components="{OpenIndicator}" />
|
<v-select :components="{OpenIndicator}" />
|
||||||
```
|
```
|
||||||
```js
|
```js
|
||||||
computed: {
|
export default {
|
||||||
OpenIndicator () {
|
data: () => ({
|
||||||
return Vue.component('OpenIndicator', {
|
selected: ['Canada'],
|
||||||
render (createElement) {
|
OpenIndicator: {
|
||||||
return createElement('button', '🤘🏻');
|
render: createElement => createElement('span', {class: {'toggle': true}}),
|
||||||
},
|
},
|
||||||
});
|
}),
|
||||||
},
|
};
|
||||||
},
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<OpenIndicatorOverride />
|
<OpenIndicatorOverride />
|
||||||
|
|
||||||
## Setting at Registration
|
## Setting Globally at Registration
|
||||||
|
|
||||||
If you want to all instances of Vue Select to use your custom components throughout your app, while
|
If you want to all instances of Vue Select to use your custom components throughout your app, while
|
||||||
only having to set the implementation once, you can do so when registering Vue Select as a component.
|
only having to set the implementation once, you can do so when registering Vue Select as a component.
|
||||||
@@ -67,21 +64,15 @@ only having to set the implementation once, you can do so when registering Vue S
|
|||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import vSelect from 'vue-select';
|
import vSelect from 'vue-select';
|
||||||
|
|
||||||
/**
|
|
||||||
* Create custom components to override defaults.
|
|
||||||
* @type {{OpenIndicator: *, Deselect: *}}
|
|
||||||
*/
|
|
||||||
const components = {
|
|
||||||
Deselect: Vue.component('Deselect', {
|
|
||||||
render: (createElement) => createElement('button', '❌'),
|
|
||||||
}),
|
|
||||||
OpenIndicator: Vue.component('OpenIndicator', {
|
|
||||||
render: (createElement) => createElement('span', '🔽'),
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Set the components prop default to return our fresh components
|
// Set the components prop default to return our fresh components
|
||||||
vSelect.props.components.default = () => components;
|
vSelect.props.components.default = () => ({
|
||||||
|
Deselect: {
|
||||||
|
render: createElement => createElement('button', '❌'),
|
||||||
|
},
|
||||||
|
OpenIndicator: {
|
||||||
|
render: createElement => createElement('span', '🔽'),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// Register the component
|
// Register the component
|
||||||
Vue.component(vSelect)
|
Vue.component(vSelect)
|
||||||
|
|||||||
Reference in New Issue
Block a user