-1
Good morning.
So, on the question, I’m trying to refactor my code to OO and I have the following problem:
(this is a minimum problem code that reproduces the problem)
index.html
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Um título legal</title>
</head>
<body>
<button id="btn-click">Click</button>
<script type="module" src="./main.js"></script>
</body>
</html>
Test js.
class Test {
add(level) {
level += 1;
}
}
export default new Test();
main.js
import Test from "./Test.js";
let level = 1;
document.getElementById("btn-click").addEventListener("click", () => {
Test.add(level);
console.log(level);
});
Would anyone know a possible solution?
EDIT1: It was to add level 1 when calling Test.add(level), but that’s not what happens.
Where and exactly what your mistake is?
– Maycon F. Castro
Guy opens the Chrome developer tools and sees if there’s any CQRS error think your script
main.js
is not being loaded.– Maycon F. Castro