mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-09-03 14:49:45 +08:00
docs(Style): use composition api
This commit is contained in:
parent
57c860afb8
commit
497f36a2d3
@ -62,7 +62,7 @@ const i18n = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
setup() {
|
||||||
const t = useTranslate(i18n);
|
const t = useTranslate(i18n);
|
||||||
const show = ref(false);
|
const show = ref(false);
|
||||||
|
|
||||||
|
@ -21,46 +21,54 @@
|
|||||||
</transition>
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
export default {
|
import { reactive, toRefs } from 'vue';
|
||||||
i18n: {
|
import { useTranslate } from '@demo/use-translate';
|
||||||
'zh-CN': {
|
|
||||||
hairline: '1px 边框',
|
|
||||||
ellipsis: '文字省略',
|
|
||||||
animation: '动画',
|
|
||||||
toggle: '切换动画',
|
|
||||||
text1: '这是一段最多显示一行的文字,后面的内容会省略',
|
|
||||||
text2:
|
|
||||||
'这是一段最多显示两行的文字,后面的内容会省略。这是一段最多显示两行的文字,后面的内容会省略',
|
|
||||||
},
|
|
||||||
'en-US': {
|
|
||||||
hairline: 'Hairline',
|
|
||||||
ellipsis: 'Text Ellipsis',
|
|
||||||
animation: 'Animation',
|
|
||||||
toggle: 'Switch animation',
|
|
||||||
text1:
|
|
||||||
'This is a paragraph that displays up to one line of text, and the rest of the text will be omitted.',
|
|
||||||
text2:
|
|
||||||
'This is a paragraph that displays up to two lines of text, and the rest of the text will be omitted.',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
data() {
|
const i18n = {
|
||||||
return {
|
'zh-CN': {
|
||||||
|
hairline: '1px 边框',
|
||||||
|
ellipsis: '文字省略',
|
||||||
|
animation: '动画',
|
||||||
|
toggle: '切换动画',
|
||||||
|
text1: '这是一段最多显示一行的文字,后面的内容会省略',
|
||||||
|
text2:
|
||||||
|
'这是一段最多显示两行的文字,后面的内容会省略。这是一段最多显示两行的文字,后面的内容会省略',
|
||||||
|
},
|
||||||
|
'en-US': {
|
||||||
|
hairline: 'Hairline',
|
||||||
|
ellipsis: 'Text Ellipsis',
|
||||||
|
animation: 'Animation',
|
||||||
|
toggle: 'Switch animation',
|
||||||
|
text1:
|
||||||
|
'This is a paragraph that displays up to one line of text, and the rest of the text will be omitted.',
|
||||||
|
text2:
|
||||||
|
'This is a paragraph that displays up to two lines of text, and the rest of the text will be omitted.',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
const t = useTranslate(i18n);
|
||||||
|
const state = reactive({
|
||||||
show: false,
|
show: false,
|
||||||
transitionName: '',
|
transitionName: '',
|
||||||
};
|
});
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
const animate = (transitionName: string) => {
|
||||||
animate(transitionName) {
|
state.show = true;
|
||||||
this.show = true;
|
state.transitionName = transitionName;
|
||||||
this.transitionName = transitionName;
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.show = false;
|
state.show = false;
|
||||||
}, 500);
|
}, 500);
|
||||||
},
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
...toRefs(state),
|
||||||
|
t,
|
||||||
|
animate,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user