Created
October 18, 2019 00:02
-
-
Save zeroidentidad/25742616cd02bddaedac71b46ba09c06 to your computer and use it in GitHub Desktop.
JS FrontEnd: uso de modulos y exportación de clases (ES6+)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import variableModulo, {MiClase} from "./modulo.js"; | |
const texto = document.createElement("p"); | |
texto.textContent = variableModulo; | |
contenedor.appendChild(texto); | |
const obj = {propx: 'holax', propy: 'holay'} | |
const usar = new MiClase(obj, 'otro valor'); | |
usar.miFuncion(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
<script src="./app.js" type="module"></script> | |
</head> | |
<body> | |
<div id="contenedor"></div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const variableModulo = 'Valor variableModulo'; | |
export default variableModulo; | |
class Componente { | |
constructor(propiedades='Valor default') { | |
this.propiedades = propiedades; | |
} | |
funcionComponente() { | |
console.log(`Valores recibidos: ${JSON.stringify(this.propiedades)}`); | |
} | |
} | |
export class MiClase extends Componente { | |
constructor(propiedades, mipropiedad= 'Mi valor default') { | |
super(propiedades); | |
this.mipropiedad = mipropiedad; | |
} | |
miFuncion() { | |
super.funcionComponente() | |
console.log(`Mas ${JSON.stringify(this.mipropiedad)}`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment