简体   繁体   English

Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 使用 vuejs

[英]Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 using vuejs

I am trying to create a treemap based on data from a .json .我正在尝试根据来自.json的数据创建树形图。 I am using d3 and vue with to help the process.我正在使用 d3 和 vue 来帮助这个过程。 When I try and load my data using the d3.json() function and outputting to console I get the error当我尝试使用d3.json() function 加载数据并输出到控制台时出现错误

Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
d3.json('./warehouses').then(function(error,data) {
  data = data.concat(json)
  render(data)
  console.log(data)
})

if you want to load a json file, you should import it.如果要加载 json 文件,则应将其导入。 the code looks like this:代码如下所示:
import data from '../addressOfJsonFile/db.json';
then you can use data variable you imported as your json object.然后您可以使用您作为 json object 导入的数据变量。 note that you can name your json imported whatever you want.请注意,您可以随意命名您的 json 导入。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获(承诺)SyntaxError:JSON 中位置 0 的意外标记 &lt; - Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 如何修复“Uncaught (in promise) SyntaxError: Unexpected token &lt; in JSON at position 0”错误 - How to fix “Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0” ERROR Redux 应用程序错误:未捕获(承诺中) SyntaxError:意外令牌 &lt; 在 position 0 处的 JSON - Redux app error: Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 Uncaught (in promise) SyntaxError: Unexpected token N in JSON at position 0 - Uncaught (in promise) SyntaxError: Unexpected token N in JSON at position 0 Django : Uncaught (in promise) SyntaxError: Unexpected token &lt; in JSON at position 0 - Django : Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 未捕获的 Promise Rejection SyntaxError: Unexpected token u in JSON at position 0 - Uncaught Promise Rejection SyntaxError: Unexpected token u in JSON at position 0 Uncaught (in promise) SyntaxError: Unexpected token &lt; in JSON at position 0 (React/Redux App) - Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 (React/Redux App) React Js: Uncaught (in promise) SyntaxError: Unexpected token &lt; in JSON at position 0 - React Js: Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 VM101:1 Uncaught (in promise) SyntaxError: Unexpected token &lt; in JSON at position 0 - VM101:1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 未捕获(承诺)SyntaxError:意外令牌 < in JSON at position 0 来自 SpringBoot API - Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 from SpringBoot API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM