docs_vue2/one/docs/demo/config-provider/select.vue
xdm 1b98a996ff
docs: add docs for carousel and config-provider (#8)
* docs: add docs for carousel and config-provider
2021-09-15 19:04:39 +08:00

57 lines
1.1 KiB
Vue

<template>
<article>
<veui-button
style="margin-right: 8px;"
@click="toggle"
>切换</veui-button>
<veui-config-provider :value="value">
<veui-select
:options="options"
clearable
/>
</veui-config-provider>
</article>
</template>
<script>
import { Select, ConfigProvider, Button } from 'veui'
const PLACEHOLDER1 = '请选择协议1'
const PLACEHOLDER2 = '请选择协议2'
// Select 的 placeholder 会响应配置 `select.placeholder`
export default {
components: {
'veui-config-provider': ConfigProvider,
'veui-select': Select,
'veui-button': Button
},
data () {
return {
value: {
'select.placeholder': PLACEHOLDER1
},
options: [
{
label: 'MIT',
value: 'mit'
},
{
label: 'BSD',
value: 'bsd'
}
]
}
},
methods: {
toggle () {
let prev = this.value['select.placeholder']
this.value['select.placeholder'] = prev === PLACEHOLDER1
? PLACEHOLDER2
: PLACEHOLDER1
}
}
}
</script>