docs(NavBar): use setup

This commit is contained in:
chenjiahan
2020-12-15 15:21:31 +08:00
parent 872bf4ddfb
commit 775f0bef47
5 changed files with 59 additions and 33 deletions

View File

@@ -19,24 +19,36 @@
</demo-block>
</template>
<script>
export default {
i18n: {
'zh-CN': {
useSlot: '使用插槽',
},
'en-US': {
useSlot: 'Use Slot',
},
},
<script lang="ts">
import { useTranslate } from '@demo/use-translate';
import Toast from '../../toast';
methods: {
onClickLeft() {
this.$toast(this.t('back'));
},
onClickRight() {
this.$toast(this.t('button'));
},
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>