En mi archivo html, cuando hago clic en el botón, llamará a una función en el archivo home.js.
Archivo index.html:
<body> <button onclick="ShowMyAlert()"></button> <script src="/js/home.js"></script> </body>Y la función llamará a otra función en el archivo cUtilitiesForm.js. Archivo home.js:
var x = require('./cUtilitiesForm') function ShowMyAlert() { x.ShowAlertSuccess('Good job') }Archivo cUtilitiesForm.js:
function ShowAlertSuccess(title) { Swal.fire( `${title}`, 'success' ) } module.exports = { ShowAlertSuccess: showAlertSuccess, }Y luego hago clic en el botón, dará un error:
home.js:4 Uncaught TypeError: Cannot read properties of undefined (reading 'ShowAlertSuccess') at ShowMyAlert (home.js:4) at HTMLButtonElement.onclick ((index):52)no se si esto es posible o no