Initial commit: caddy static file server workspace
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
10
caddy/www/module-demo/main.js
Normal file
10
caddy/www/module-demo/main.js
Normal file
@@ -0,0 +1,10 @@
|
||||
// 匯入指定函式與常數
|
||||
import { add, PI } from './math.js';
|
||||
|
||||
// 匯入預設匯出
|
||||
import multiply from './math.js';
|
||||
|
||||
console.log(add(2, 3)); // 5
|
||||
console.log(PI); // 3.14159
|
||||
console.log(multiply(4, 5));// 20
|
||||
|
||||
13
caddy/www/module-demo/math.js
Normal file
13
caddy/www/module-demo/math.js
Normal file
@@ -0,0 +1,13 @@
|
||||
// 匯出函式
|
||||
export function add(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
// 匯出常數
|
||||
export const PI = 3.14159;
|
||||
|
||||
// 預設匯出(每個檔案只能有一個)
|
||||
export default function multiply(a, b) {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
2
caddy/www/module-demo/myfile.html
Normal file
2
caddy/www/module-demo/myfile.html
Normal file
@@ -0,0 +1,2 @@
|
||||
<script type="module" src="main.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user