refactor: demo using script setup (#9235)
This commit is contained in:
+18
-28
@@ -1,3 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import { useTranslate } from '@demo/use-translate';
|
||||
import { Toast } from '../../toast';
|
||||
|
||||
const i18n = {
|
||||
'zh-CN': {
|
||||
useSlot: '使用插槽',
|
||||
},
|
||||
'en-US': {
|
||||
useSlot: 'Use Slot',
|
||||
},
|
||||
};
|
||||
|
||||
const t = useTranslate(i18n);
|
||||
const onClickLeft = () => Toast(t('back'));
|
||||
const onClickRight = () => Toast(t('button'));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<demo-block :title="t('basicUsage')">
|
||||
<van-nav-bar
|
||||
@@ -18,31 +36,3 @@
|
||||
</van-nav-bar>
|
||||
</demo-block>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { useTranslate } from '@demo/use-translate';
|
||||
import { Toast } from '../../toast';
|
||||
|
||||
const i18n = {
|
||||
'zh-CN': {
|
||||
useSlot: '使用插槽',
|
||||
},
|
||||
'en-US': {
|
||||
useSlot: 'Use Slot',
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const t = useTranslate(i18n);
|
||||
const onClickLeft = () => Toast(t('back'));
|
||||
const onClickRight = () => Toast(t('button'));
|
||||
|
||||
return {
|
||||
t,
|
||||
onClickLeft,
|
||||
onClickRight,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user