Skip to content

Commit

Permalink
feat(demo): add JsonPreview demo
Browse files Browse the repository at this point in the history
添加JsonPreview组件的使用演示

close: #1146
  • Loading branch information
mynetfan committed Sep 6, 2021
1 parent 044e2e4 commit 83c1683
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/views/demo/editor/json/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</PageWrapper>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
import { CodeEditor } from '/@/components/CodeEditor';
import { defineComponent, ref, unref, h } from 'vue';
import { CodeEditor, JsonPreview } from '/@/components/CodeEditor';
import { PageWrapper } from '/@/components/Page';
import { Radio, Space, Modal } from 'ant-design-vue';
Expand Down Expand Up @@ -82,7 +82,14 @@
}
function showData() {
Modal.info({ title: '编辑器当前值', content: value.value });
if (unref(modeValue) === 'application/json') {
Modal.info({
title: '编辑器当前值',
content: h(JsonPreview, { data: JSON.parse(value.value) }),
});
} else {
Modal.info({ title: '编辑器当前值', content: value.value });
}
}
return { value, modeValue, handleModeChange, showData };
Expand Down

0 comments on commit 83c1683

Please sign in to comment.