Uncaught TypeError:无法读取main.js上未定义的属性“ render”:48

时间:2019-09-20 11:48:17

标签: javascript node.js

我是编程新手。我想在浏览器上渲染画布

我的代码在这里

// implement canvas js
let dataPoints = [
    {label: 'One', y: 0},
    {label: 'Two', y: 0},
    {label: 'Three', y: 0},
    {label: 'Four', y: 0}
];

const myContainer = document.querySelector(
    '#mytContainer'
);

if(cmytContainer){
    const chart = CanvasJS.Chart('mytContainer', {
        animationEnabled: true,
        theme: 'theme1',
        title: {
            text: 'My Results'
        },
        data: [
            {
                type: 'column',
                dataPoints: dataPoints
            }
        ]
    });
    chart.return()
}

请帮助一下。 预先感谢

1 个答案:

答案 0 :(得分:0)

我认为错误是由于条件变量拼写更改为myContainer

let dataPoints = [
    {label: 'One', y: 0},
    {label: 'Two', y: 0},
    {label: 'Three', y: 0},
    {label: 'Four', y: 0}
];

const myContainer = document.querySelector(
    '#mytContainer'
);

if(myContainer){
    const chart = CanvasJS.Chart('mytContainer', {
        animationEnabled: true,
        theme: 'theme1',
        title: {
            text: 'My Results'
        },
        data: [
            {
                type: 'column',
                dataPoints: dataPoints
            }
        ]
    });
    chart.return()
}