Javascript 未捕获类型错误:无法读取属性';渲染';main.js:48中未定义的
我是编程新手。我想在浏览器上渲染画布 我的代码在这里Javascript 未捕获类型错误:无法读取属性';渲染';main.js:48中未定义的,javascript,node.js,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(
// 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()
}
请身边的人帮忙。
提前感谢我认为错误是由于条件变量输入错误更改为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()
}
在哪里调用渲染函数?您应该提供更多的代码。或者是否有输入错误,“return()”应该是“render()”?您确定正确包含了ChartJS库吗?