mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-07 02:28:54 +08:00
Initial commit
This commit is contained in:
35
src/components/SqlTable.vue
Normal file
35
src/components/SqlTable.vue
Normal file
@@ -0,0 +1,35 @@
|
||||
<template>
|
||||
<vue-good-table v-if="data" :columns="columns" :rows="rows"/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import 'vue-good-table/dist/vue-good-table.css'
|
||||
import { VueGoodTable } from 'vue-good-table'
|
||||
|
||||
export default {
|
||||
name: 'SqlTable',
|
||||
components: { VueGoodTable },
|
||||
props: ['data'],
|
||||
computed: {
|
||||
columns () {
|
||||
const columns = []
|
||||
this.data.columns.forEach(column => {
|
||||
columns.push({ label: column, field: column })
|
||||
})
|
||||
return columns
|
||||
},
|
||||
rows () {
|
||||
const rows = []
|
||||
this.data.values.forEach(row => {
|
||||
const newRow = {}
|
||||
row.forEach((value, index) => {
|
||||
const column = this.data.columns[index]
|
||||
newRow[column] = value
|
||||
})
|
||||
rows.push(newRow)
|
||||
})
|
||||
return rows
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user