Installation
npm install vue-json-viewer --save-dev
// or
yarn add vue-json-viewer -D
Options
| Property |
Description |
Default |
| value |
JSON data (can be used with v-model) |
Required |
| expand-depth |
Collapse blocs under this depth |
1 |
| copyable |
Display the copy button, you can customize copy text just set {copyText: 'copy', copiedText: 'copied', timeout: 2000} or set true use default copytext |
false |
| sort |
Sort keys before displaying |
false |
| boxed |
Add a fancy "boxed" style to component |
false |
| theme |
Add a custom CSS class for theming purposes |
jv-light |
| expanded |
Default expand the view |
false |
| timeformat |
custom time format function |
time => time.toLocaleString() |
| preview-mode |
no expand mode |
false |
| array show index |
array show index |
true |
| show-double-quotes |
show double quotes |
false |
Listeners
| Listener |
Description |
Value |
| copied |
Emits copyEvent after text copied |
Clipboard success event |
| keyclick |
click key event |
Slots
| Name |
Description |
Scope |
| copy |
Custom content for copy button |
{copied: boolean} |
Using
<template>
<vue-json-viewer :value="jsonData"></vue-json-viewer>
</template>
<script>
import JsonViewer from 'vue-json-viewer'
export default {
name: 'Template',
data () {
jsonData: {
user: '孙悟空',
weapon: '金箍棒',
age: '800+',
brothers: ['猪八戒', '沙悟净']
}
}
}
</script>
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。