Created
January 31, 2026 06:29
-
-
Save joannewang0807-prog/e09d6e782f7d0add6a87a20e22da03b3 to your computer and use it in GitHub Desktop.
2026
This file contains hidden or 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
| // 1. 定義各國匯率 (2026 參考匯率,可自行調整) | |
| const exchangeRates = { | |
| '大阪': { cur: 'JPY', rate: 0.21, sign: '¥' }, | |
| '京都': { cur: 'JPY', rate: 0.21, sign: '¥' }, | |
| '神戶': { cur: 'JPY', rate: 0.21, sign: '¥' }, | |
| '曼谷': { cur: 'THB', rate: 0.92, sign: '฿' }, | |
| '清邁': { cur: 'THB', rate: 0.92, sign: '฿' }, | |
| '檳城': { cur: 'MYR', rate: 7.10, sign: 'RM' } | |
| }; | |
| // 2. 換算器用的響應式變數 | |
| const inputAmount = ref(100); | |
| // 3. 根據目前選取的城市取得匯率資訊 | |
| const currentRateInfo = computed(() => { | |
| return exchangeRates[currentCity.value] || { cur: 'JPY', rate: 0.21, sign: '¥' }; | |
| }); | |
| // 4. 計算結果 | |
| const twdResult = computed(() => { | |
| return (inputAmount.value * currentRateInfo.value.rate).toLocaleString(undefined, {maximumFractionDigits: 0}); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment