2
0
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:
陈峰
2019-05-31 22:53:11 +08:00
parent 4e7e1ac8b5
commit 6e7c4eb113
5 changed files with 30 additions and 22 deletions
+1 -1
View File
@@ -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
+9 -1
View File
@@ -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()}"`
}
})
}