我一直在寻找如何解决这个错误,但我不太了解如何修复它。
我在一个项目上使用 lottie-web,我必须在一个对象上设置动画的参数,以便稍后将其作为参数传递。
我的组件:
import Lottie from './../../node_modules/lottie-web/build/player/lottie';
export default {
name: 'Illustration',
mounted() {
this.animationParams = {
container: document.getElementById('animation'),
renderer: 'svg',
loop: 'true',
autoplay: 'false',
path: '/src/data/animation.json',
};
Lottie.loadAnimation(this.animationParams);
},
data() {
return {
animationParams: {
},
};
},
但是当这行被执行时:
Lottie.loadAnimation(this.animationParams);
我收到此错误:
Uncaught SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at XMLHttpRequest.xhr.onreadystatechange
我在 Stackoverflow 的其他答案中看到的是,我不必解析 json,因为它已经解析了,但我不知道如何不解析它。
这是 json 文件中的内容:http: //myjson.com/s0kn6。
我如何在不解析的情况下加载该 json 文件?