Error: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node' while using a spinner in JavaScript

Error: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node' while using a spinner in JavaScript

我在 https://spin.js.org/ 引用的 javascript 代码中实现了一个微调器,但出现错误 -

Error: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'

代码:

app.js

    render() {


    var opts = {
        lines: 13, // The number of lines to draw
        length: 38, // The length of each line
        width: 17, // The line thickness
        radius: 45, // The radius of the inner circle
        scale: 1, // Scales overall size of the spinner
        corners: 1, // Corner roundness (0..1)
        color: '#5229cc', // CSS color or array of colors
       //more
      };

       var target = document.getElementById('viz');
    //  var spinner = new Spinner(opts).spin(target);

        var spinner = new Spinner().spin();
        target.appendChild(spinner.el);


          //code
                },
                onCompleted: function () {
                    var target = document.getElementById('viz');
                    var spinner = new Spinner().stop();

                    target.appendChild(spinner.el);


                  session.close();
                 //code

        };

可能您在 onCompleted 函数中遇到了错误。

我认为您应该删除 onCompleted 函数中的 target.appendChild(spinner.el);

根据https://spin.js.org/

To hide the spinner, invoke the stop() method, which removes the UI elements from the DOM and stops the animation. Stopped spinners may be reused by calling spin() again.