提交 8aa018d6 编写于 作者: View Design's avatar View Design

Update Chart.global.vue

上级 0bc38b77
......@@ -26,7 +26,7 @@ const props = defineProps({
}
})
let chart
onMounted(() => {
function init () {
chart = new Chart(document.getElementById('chart'), {
type: props.type,
data: {
......@@ -42,10 +42,23 @@ onMounted(() => {
}
}
})
}
function destroy () {
if (chart) chart.destroy()
}
onMounted(() => {
init()
})
onBeforeUnmount(() => {
destroy()
})
watch(()=> colorMode.value, (value) => {
let color = '#e5e7eb'
if (value === 'dark') color = '#1f2937'
Chart.defaults.borderColor = color
if (chart) {
destroy()
init()
}
}, { immediate: true, deep: true })
</script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册