Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vue.js 在vue good表中显示neo4j数据库中的数据_Vue.js_Neo4j_Vue Good Table - Fatal编程技术网

Vue.js 在vue good表中显示neo4j数据库中的数据

Vue.js 在vue good表中显示neo4j数据库中的数据,vue.js,neo4j,vue-good-table,Vue.js,Neo4j,Vue Good Table,我正在使用一种方法从我的neo4j数据库检索数据。我想将输出放入一个vue良好的表中。这就是我使用的方法 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, para

我正在使用一种方法从我的neo4j数据库检索数据。我想将输出放入一个vue良好的表中。这就是我使用的方法

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();
    });
}
我在网上搜索了很多解决方案,但我不断地发现这个错误

**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

有人能告诉我哪里出了问题吗?

看来您只是从数据库中检索名称,它是一个字符串。不是JSON字符串,因此解码它是无用的。要创建一个对象,以便:

this.rows.push({ name: this.data });
这会将具有1个属性
名称
和数据库值的对象推送到数组中


并不是说您只处理数据库中的一条记录。您需要一个循环来循环所有记录。

Hi,您能分享
console.log(res)
语句的输出吗?
vue-good-table.vue?0ccb:237 Uncaught (in promise) SyntaxError: Unexpected token s in JSON at position 0
this.rows.push({ name: this.data });