我正在使用一种方法从我的 neo4j 数据库中检索数据。我想将输出放入一个 vue-good 表中。这是我使用的方法
testQuery() {
var _this=this
// Get a session from the driver
const session = this.$neo4j.getSession();
var arr = [];
var arr1 = [];
// Or you can just call this.$neo4j.run(cypher, params)
session
.run("MATCH (Ind:Country {name: 'India', result: 'Winners'})<-[: TOP_SCORER_OF]-(n) RETURN n.name AS data")
.then(res => {
this.data = res.records[0].get("data");
console.log(res)
//var x = JSON.parse(this.data);
console.log(this.data)
this.rows.push(this.data);
})
.then(() => {
session.close();
});
}
我这样称呼vue good table -
<vue-good-table
:columns="columns"
:line-numbers="true"
:search-options="{
enabled: true,
placeholder: 'Search this table'}"
:pagination-options="{
enabled: true,
mode: 'records'}"
styleClass="tableOne vgt-table"
:selectOptions="{
enabled: true,
selectionInfoClass: 'table-alert__box' }"
:rows="rows">
<!-- <div slot="table-actions" class="mb-3">
<b-button variant="primary" class="btn-rounded">
Add Button
</b-button>
</div>-->
<template slot="table-row" slot-scope="props">
<span v-if="props.column.field == 'button'">
<a href>
<i class="i-Eraser-2 text-25 text-success mr-2"></i>
{{ props.row.button }}
</a>
<a href>
<i class="i-Close-Window text-25 text-danger"></i>
{{ props.row.button }}
</a>
</span>
</template>
</vue-good-table>
我已经定义了这样的行和列 -
columns: [
{
label: "Name",
field: "name"
},
{
label: "Created On",
field: "createdAt",
type: "date",
dateInputFormat: "yyyy-mm-dd",
dateOutputFormat: "MMM Do yy",
tdClass: "text-left",
thClass: "text-left"
},
{
label: "Percent",
field: "score",
type: "percentage",
tdClass: "text-left",
thClass: "text-left"
}
],
rows: []
我在网上搜索了许多解决方案,但我不断收到此错误
**TypeError:** Cannot create property 'vgt_id' on string 'shikar Dhawan'
人们已经回答了类似的问题,说您需要将字符串转换为 js 对象,但后来我收到了这个错误-
vue-good-table.vue?0ccb:237 Uncaught (in promise) SyntaxError: Unexpected token s in JSON at position 0
有人能告诉我哪里出错了吗?