Calculator ❤️

🔸 心得1. Table layout2. Grid layout3. Web Component ❤️

simple calculator

心得

<!-- 📁 index.html -->
<script type="module" src="calc-app/calc-app.js"></script>

module 透過 customElements.define( ) 讀進來的 class CalcApp,可以直接用嗎❓例如:const app = new CalcApp( );

答案是:可以❗️但 export/import 還是要先做❗️ 👉🏻 ES Modules

// ⭐️ 1. export class (📁 calc-app.js)
export default class CalcApp extends HTMLElement { ... }

// ⭐️ 2. import class (📁 main.js)
import CalcApp from './calc-app/calc-app.js';

Code

v.1:Table layout (original)

Table layout

v.2:Grid layout

Grid layout

v.3:Web Componet

CodeSandbox

Last updated