The `console.log(123)` statement may not be working because it is placed inside the `window.addEventListener('DOMContentLoaded', () => {...})` callback function. This callback function is executed when the DOM content has finished loading.\n\nIf you are not seeing the console output, it could be due to a few reasons:\n1. Make sure that the `onMounted()` function is being called correctly and at the right time. Check if the component or hook that contains this code is being rendered and mounted properly.\n2. Ensure that the DOM element with the ID "hearChart" exists in the HTML markup. If it does not exist, the `document.getElementById('hearChart')` call will return `null`, and the `chart` variable will not be initialized.\n3. Check if there are any errors or exceptions occurring before the `console.log(123)` statement. If there are any errors, they might prevent the subsequent code from executing.\n4. Verify if the ECharts library is imported and available in the current scope. If the library is not properly imported or initialized, it might cause issues with the `chart` variable.\n\nBy checking these aspects, you should be able to identify the cause of the console not being effective.

Why console.log is not working in onMounted and DOMContentLoaded callback?

原文地址: https://www.cveoy.top/t/topic/p3rz 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录