在h5中用scrpit的src引入u-charts.min.js報(bào)錯(cuò)ReferenceError:?uCharts?is?not?defined
將u-charts.min.js最后一句的export default uCharts去掉就可以了
運(yùn)行未報(bào)錯(cuò)舶担,但圖表不顯示
在使用ucharts時(shí),圖表不在當(dāng)前頁簽,顯示圖表的事件放在mounted里面躏啰,導(dǎo)致圖表不顯示轿曙,也沒有任何報(bào)錯(cuò)组去,經(jīng)查原因是offsetWidth 一定要對(duì)象顯示出來了才能獲取,否則獲取的為0
基于這情況就將顯示事件放在點(diǎn)擊標(biāo)簽的事件中
圖表不清晰?要設(shè)定好pixelRatio
const ctx = canvas.getContext("2d");
const pixel = window.devicePixelRatio;
canvas.width = canvas.offsetWidth * pixel;
canvas.height = canvas.offsetHeight * pixel;
然后在new uCharts({})中設(shè)定pixelRatio
width: canvas.width,
?height: canvas.height,
pixelRatio: pixel,
2022-11-26