docs(Form): fix Picker demo

This commit is contained in:
chenjiahan 2022-02-20 20:54:07 +08:00
parent 0b4b04eefb
commit 9cfef027aa
3 changed files with 23 additions and 10 deletions

View File

@ -342,10 +342,16 @@ export default {
setup() {
const result = ref('');
const showPicker = ref(false);
const columns = ['Delaware', 'Florida', 'Georqia', 'Indiana', 'Maine'];
const columns = [
{ text: 'Delaware', value: 'Delaware' },
{ text: 'Florida', value: 'Florida' },
{ text: 'Georqia', value: 'Georqia' },
{ text: 'Indiana', value: 'Indiana' },
{ text: 'Maine', value: 'Maine' },
];
const onConfirm = (value) => {
result.value = value;
result.value = selectedOptions[0]?.text;
showPicker.value = false;
};

View File

@ -368,10 +368,16 @@ export default {
setup() {
const result = ref('');
const showPicker = ref(false);
const columns = ['杭州', '宁波', '温州', '嘉兴', '湖州'];
const columns = [
{ text: '杭州', value: 'Hangzhou' },
{ text: '宁波', value: 'Ningbo' },
{ text: '温州', value: 'Wenzhou' },
{ text: '绍兴', value: 'Shaoxing' },
{ text: '湖州', value: 'Huzhou' },
];
const onConfirm = (value) => {
result.value = value;
result.value = selectedOptions[0]?.text;
showPicker.value = false;
};

View File

@ -1,28 +1,29 @@
<script setup lang="ts">
import VanField from '../../field';
import VanPopup from '../../popup';
import VanPicker from '../../picker';
import VanPicker, { PickerConfirmEventParams } from '../../picker';
import { ref } from 'vue';
import { useTranslate } from '../../../docs/site/use-translate';
import { basicColumns } from '../../picker/demo/data';
const t = useTranslate({
'zh-CN': {
picker: '选择器',
placeholder: '点击选择城市',
textColumns: ['杭州', '宁波', '温州', '嘉兴', '湖州'],
textColumns: basicColumns['zh-CN'],
},
'en-US': {
picker: 'Picker',
placeholder: 'Select city',
textColumns: ['Delaware', 'Florida', 'Georqia', 'Indiana', 'Maine'],
textColumns: basicColumns['en-US'],
},
});
const result = ref('');
const result = ref<string | number>('');
const showPicker = ref(false);
const onConfirm = (value: string) => {
result.value = value;
const onConfirm = ({ selectedOptions }: PickerConfirmEventParams) => {
result.value = selectedOptions[0]?.text || '';
showPicker.value = false;
};