mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore(ActionSheet): use tsx (#8071)
This commit is contained in:
parent
66963db3ed
commit
3da3dfe7dd
@ -51,9 +51,10 @@
|
||||
</van-action-sheet>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { computed, reactive, toRefs } from 'vue';
|
||||
import { useTranslate } from '@demo/use-translate';
|
||||
import { ActionSheetAction } from '..';
|
||||
import Toast from '../../toast';
|
||||
|
||||
const i18n = {
|
||||
@ -100,28 +101,29 @@ export default {
|
||||
},
|
||||
});
|
||||
|
||||
const simpleActions = computed(() => [
|
||||
const simpleActions = computed<ActionSheetAction[]>(() => [
|
||||
{ name: t('option1') },
|
||||
{ name: t('option2') },
|
||||
{ name: t('option3') },
|
||||
]);
|
||||
|
||||
const statusActions = computed(() => [
|
||||
const statusActions = computed<ActionSheetAction[]>(() => [
|
||||
{ name: t('coloredOption'), color: '#ee0a24' },
|
||||
{ name: t('disabledOption'), disabled: true },
|
||||
{ loading: true },
|
||||
]);
|
||||
|
||||
const actionsWithDescription = computed(() => [
|
||||
const actionsWithDescription = computed<ActionSheetAction[]>(() => [
|
||||
{ name: t('option1') },
|
||||
{ name: t('option2') },
|
||||
{ name: t('option3'), subname: t('subname') },
|
||||
]);
|
||||
|
||||
const onSelect = (item) => {
|
||||
const onSelect = (item: ActionSheetAction) => {
|
||||
state.show.basic = false;
|
||||
Toast(item.name);
|
||||
};
|
||||
|
||||
const onCancel = () => Toast(t('cancel'));
|
||||
|
||||
return {
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { PropType } from 'vue';
|
||||
|
||||
// Utils
|
||||
import { createNamespace, pick } from '../utils';
|
||||
|
||||
@ -8,11 +10,21 @@ import Loading from '../loading';
|
||||
|
||||
const [createComponent, bem] = createNamespace('action-sheet');
|
||||
|
||||
export type ActionSheetAction = {
|
||||
name?: string;
|
||||
color?: string;
|
||||
subname?: string;
|
||||
loading?: boolean;
|
||||
disabled?: boolean;
|
||||
callback?: (action: ActionSheetAction) => void;
|
||||
className?: any;
|
||||
};
|
||||
|
||||
export default createComponent({
|
||||
props: {
|
||||
...popupSharedProps,
|
||||
title: String,
|
||||
actions: Array,
|
||||
actions: Array as PropType<ActionSheetAction[]>,
|
||||
cancelText: String,
|
||||
description: String,
|
||||
closeOnPopstate: Boolean,
|
||||
@ -40,7 +52,7 @@ export default createComponent({
|
||||
setup(props, { slots, emit }) {
|
||||
const popupPropKeys = Object.keys(popupSharedProps);
|
||||
|
||||
const onUpdateShow = (show) => {
|
||||
const onUpdateShow = (show: boolean) => {
|
||||
emit('update:show', show);
|
||||
};
|
||||
|
||||
@ -77,7 +89,7 @@ export default createComponent({
|
||||
}
|
||||
};
|
||||
|
||||
const renderOption = (item, index) => {
|
||||
const renderOption = (item: ActionSheetAction, index: number) => {
|
||||
const {
|
||||
name,
|
||||
color,
|
Loading…
x
Reference in New Issue
Block a user