mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-09-05 07:29:46 +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,9 +21,11 @@
|
|||||||
</transition>
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
export default {
|
import { reactive, toRefs } from 'vue';
|
||||||
i18n: {
|
import { useTranslate } from '@demo/use-translate';
|
||||||
|
|
||||||
|
const i18n = {
|
||||||
'zh-CN': {
|
'zh-CN': {
|
||||||
hairline: '1px 边框',
|
hairline: '1px 边框',
|
||||||
ellipsis: '文字省略',
|
ellipsis: '文字省略',
|
||||||
@ -43,24 +45,30 @@ export default {
|
|||||||
text2:
|
text2:
|
||||||
'This is a paragraph that displays up to two lines of text, and the rest of the text will be omitted.',
|
'This is a paragraph that displays up to two lines of text, and the rest of the text will be omitted.',
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
|
|
||||||
data() {
|
export default {
|
||||||
return {
|
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