Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.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
React-native:Json.stringify无法序列化循环结构_React Native - Fatal编程技术网

React-native:Json.stringify无法序列化循环结构

React-native:Json.stringify无法序列化循环结构,react-native,React Native,使用canvas属性时出现了此问题 我尝试使用canvas属性在react native中创建轮盘赌。我成功地使用了canvas,但我不能使用ctx.drawImage方法。当我尝试使用它们时,我得到了如下错误 Stringify无法序列化循环结构 这是一个密码狙击手 componentDidMount(){ wheelCanvas = this.updateCanvas(); } // This is in error while re

使用canvas属性时出现了此问题

我尝试使用canvas属性在react native中创建轮盘赌。我成功地使用了canvas,但我不能使用
ctx.drawImage
方法。当我尝试使用它们时,我得到了如下错误

Stringify无法序列化循环结构

这是一个密码狙击手

            componentDidMount(){
            wheelCanvas = this.updateCanvas();
    }

// This is in error while rendering : 

            ctx.drawImage(wheelCanvas, wheelCanvas.width / 2, wheelCanvas.height / 2);

            updateCanvas() {
            var outsideRadius = 120;
            var textRadius = 100;
            var insideRadius = 30;
            var canvas = this.refs.canvasRoulette;
            let ctx = canvas.getContext("2d");
            canvas.width = canvas.height = outsideRadius * 2 + 6;

            var x = outsideRadius + 3;
            var y = outsideRadius + 3;

            ctx.font = "bold 18px Helvetica, Arial";

            for (var i = 0; i < rouletteSize; i++) {
              var angle = i * arc;
              ctx.fillStyle = colors[i];
              ctx.beginPath();
              ctx.arc(x, y, outsideRadius, angle, angle + arc, false);
              ctx.arc(x, y, insideRadius, angle + arc, angle, true);
              ctx.strokeStyle = "#fff";
              ctx.lineWidth = 1;
              ctx.stroke();
              ctx.fill();
              ctx.save();
              ctx.shadowOffsetX = -1;
              ctx.shadowOffsetY = -1;
              ctx.shadowBlur = 0;
              ctx.shadowColor = "rgb(220,220,220)";
              ctx.fillStyle = "#fff";
              ctx.translate(
                x + Math.cos(angle + arc / 2) * textRadius,
                y + Math.sin(angle + arc / 2) * textRadius
              );

              ctx.rotate(angle + arc / 2 + Math.PI);
              var text = numbers[i];
              ctx.fillText(text, -ctx.measureText(text).width / 2, 5);
              ctx.restore();
            }
            return canvas;
            }
componentDidMount(){
wheelCanvas=this.updateCanvas();
}
//渲染时出现错误:
ctx.drawImage(wheelCanvas,wheelCanvas.width/2,wheelCanvas.height/2);
updateCanvas(){
var=120;
var textRadius=100;
var insideRadius=30;
var canvas=this.refs.canvasRoulette;
设ctx=canvas.getContext(“2d”);
canvas.width=canvas.height=2+6;
var x=阿迪乌斯+3;
var y=0.2×0.3;
ctx.font=“bold 18px Helvetica,Arial”;
对于(var i=0;i<轮盘赌化;i++){
var角度=i*弧;
ctx.fillStyle=颜色[i];
ctx.beginPath();
ctx.弧(x,y,半径,角度,角度+弧,假);
ctx.弧(x,y,内半径,角度+弧,角度,真值);
ctx.strokeStyle=“#fff”;
ctx.lineWidth=1;
ctx.stroke();
ctx.fill();
ctx.save();
ctx.shadowOffsetX=-1;
ctx.shadowOffsetY=-1;
ctx.shadowBlur=0;
ctx.shadowColor=“rgb(220220)”;
ctx.fillStyle=“#fff”;
ctx.translate(
x+数学cos(角度+圆弧/2)*文本半径,
y+数学正弦(角度+圆弧/2)*文本半径
);
ctx.旋转(角度+圆弧/2+数学PI);
变量文本=数字[i];
ctx.fillText(text,-ctx.measureText(text).width/2,5);
ctx.restore();
}
返回画布;
}

当json是循环的,比如a:{b},b:{a}时,通常会发生这种情况。您在哪里使用json.Stringify?还有,什么是ctx,它是对某个东西的画布引用吗?请添加完整的代码,以便我们可以更好地查看。