docs: demo ts (#8196)

This commit is contained in:
neverland
2021-02-22 20:36:59 +08:00
committed by GitHub
parent 5a86b8efb0
commit f4698ebf44
7 changed files with 49 additions and 39 deletions
+7 -7
View File
@@ -33,10 +33,10 @@
</demo-block>
</template>
<script>
<script lang="ts">
import { reactive, toRefs } from 'vue';
import { useTranslate } from '@demo/use-translate';
import ImagePreview from '..';
import ImagePreview, { ImagePreviewOptions } from '..';
import Toast from '../../toast';
const i18n = {
@@ -49,7 +49,7 @@ const i18n = {
customConfig: '传入配置项',
startPosition: '指定初始位置',
componentCall: '组件调用',
index: (index) => `${index + 1}`,
index: (index: number) => `${index + 1}`,
},
'en-US': {
closed: 'closed',
@@ -60,7 +60,7 @@ const i18n = {
customConfig: 'Custom Config',
startPosition: 'Set Start Position',
componentCall: 'Component Call',
index: (index) => `Page: ${index}`,
index: (index: number) => `Page: ${index}`,
},
};
@@ -92,11 +92,11 @@ export default {
state.show = true;
};
const onChange = (index) => {
const onChange = (index: number) => {
state.index = index;
};
const showImagePreview = (options = {}) => {
const showImagePreview = (options: Partial<ImagePreviewOptions> = {}) => {
const instance = ImagePreview({
images,
...options,
@@ -104,7 +104,7 @@ export default {
if (options.beforeClose) {
setTimeout(() => {
instance.close();
instance?.close();
}, 2000);
}
};