mirror of
https://github.com/tenrok/vue-json-viewer.git
synced 2026-06-20 20:00:37 +03:00
highlight links & fix some issue
This commit is contained in:
@@ -26,7 +26,7 @@ export default {
|
||||
}
|
||||
|
||||
const ordered = {}
|
||||
Object.keys(this.jsonValue).sort().forEach(key => {
|
||||
Object.keys(this.jsonValue).forEach(key => {
|
||||
ordered[key] = this.jsonValue[key]
|
||||
})
|
||||
return ordered
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script>
|
||||
const REG_LINK = /^\w+:\/\//;
|
||||
|
||||
export default {
|
||||
name: 'JsonString',
|
||||
functional: true,
|
||||
@@ -9,13 +11,19 @@ export default {
|
||||
}
|
||||
},
|
||||
render (h, { props }) {
|
||||
let value = props.jsonValue;
|
||||
|
||||
if (REG_LINK.test(value)) {
|
||||
value = `<a href="${value}" target="_blank" style="color: #0366d6;">${value}</a>`;
|
||||
}
|
||||
|
||||
return h('span', {
|
||||
class: {
|
||||
'jv-item': true,
|
||||
'jv-string': true,
|
||||
},
|
||||
domProps: {
|
||||
innerHTML: `"${props.jsonValue.toString()}"`
|
||||
innerHTML: `"${value.toString()}"`
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user