安裝 vue3-tel-input 國際電話輸入法套件
1 | npm i --save vue3-tel-input |
main.ts 引入
1 | import { createApp } from 'vue' |
1 | npm i --save vue3-tel-input |
main.ts 引入
1 | import { createApp } from 'vue' |
1 | npm install --save sass sass-loader |
package.json內的dependencies會有sass sass-loader的版本訊息如圖片
assets新增scss資料夾;新增檔案allStyle.scss; main.ts引入
1 | //main.ts |
src/assets/scss新增public.scss
1 | //allStyle.scss |
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
棄用警告 [import]:Sass @import 規則已棄用,將在 Dart Sass 3.0.0 中刪除。
修改方式
1 | @use "./public.scss"; |
public.scss
1 | /*建立全域變數*/ |
1 | yarn add vue-page-title # npm i --save vue-page-title |
1 | import { createApp } from 'vue'; |
1 | import { createRouter, createWebHashHistory } from 'vue-router'; |
StyleLint 是一套檢查 CSS Coding Style
1 | module.exports = { |
1 | "editor.codeActionsOnSave": { |
套用到專案
1 | // 檢查錯誤 |
或是在 package.json 內設定,透過 npm run lint:style 去執行
1 | / package.json |
dayjs官網
所有程式碼都應該在這兩種環境中運行,並且所有單元測試都在這兩種環境中運行。
目前,ci 系統使用以下瀏覽器:Windows XP 上的 Chrome、Windows 7 上的 IE 8、9 和 10、Windows 10 上的 IE 11、Linux 上最新的 Firefox 以及 OSX 10.8 和 10.11 上最新的 Safari。
cdn
1 | <!-- CDN example (jsDelivr) --> |
1 | npm install --save dayjs |
要使用語言環境和插件,您首先需要匯入目標語言和插件。
1 | import * as dayjs from 'dayjs' |
打包dayjs錯誤訊息
1 | { //tsconfig.json |
1 | npm install --save dayjs |
1 | // 引入 Day.js |
1 | const now = new Date();//等同 dayjs(new Date());"2024-04-20T05:25:08.194Z" |
1 | const now = dayjs(new Date());"2024-04-20T05:25:08.194Z"; |
1 | const timestamp = new Date().getTime(); |
1 | console.log('取得現在年份', dayjs().year()) |
1 | dayjs.extend(utc) |
1 | dayjs(null).isValid() // false |
1 | // 取得毫秒 |
1 | dayjs().format("YYYY-MM-DD HH:mm:ss"); // 2025-03-25 21:11:06 |
1 | // 取得現在日加1日 |
1 | // 計算兩個時間的時間差(天) |
1 | dayjs().startOf("day").format('YYYY/MM/DD') |
使用 valueOf() 可以將時間轉換成 unix 時間戳記
1 | dayjs().valueOf() // 1742437455396 |
參考epxress generator 安裝
node版本 14.20.1
1 | //全域方法安裝express-generator |
到此網址觀看
http://localhost:3000
1 | npm install --save mysql |
1 | npm install --save dotenv |
環境變數:新增.env
1 | //.env |
加入DB主機,使用者名稱,帳密,資料表名稱
連接MySQL資料庫 Connecting to MySQL
Create a new folder named config, and add database.js in this folder.
新增 config資料夾內新增database.js
1 | //database.js |
定義使用者
新增models/users.js
1 | //users.js |
建立控制器
新增controllers/userController.js
1 | //controllers/userController.js |
swagger.js
definitionss內的AddUser是預設參數
1 | const swaggerAutogen = require('swagger-autogen')(); |
node 14.20.1
一.Google 更改認證模式,Nodemailer 官方文件 也推薦改使用 OAuth 2.0 來介接 Gmail
建立 OAuth
Console
Cloud Google
接下來請開啟這個網址這裡,然後點一下右上齒輪,並將「Use your own OAuth credentials」打勾輸入剛剛的 Client ID 以及 Client Secret
Step2 取得Token
安裝 nodemailer
nodemailer官網
1 | npm install --save nodemailer |
新增一個頁面router
1 | // routes |
到contact 頁面
1 | var express = require('express'); |
// 完整程式碼https://github.com/hsiangfeng/node-nodemailer-finish
//https://hackmd.io/@yy933/Hy9rKyAE3?utm_source=preview-mode&utm_medium=rec
參考文獻
全端勇士之路 Node.js-OAuth 2.0 & nodemailer & Gmail
Send mails from Gmail using Nodemaile
Sending Emails with Node.js Using SMTP, Gmail, and OAuth2
Sending Emails with Node.js Using SMTP, Gmail, and OAuth2
Use Expressjs to send mails with gmail OAuth 2.0 and nodemailer
OAUTH2
Nodemailer/Gmail - What exactly is a refresh token and how do I get one?
最近要計畫想將Node express 串接Mysql 做CRUD 的Resful Api ,
所以在找可以測試的Mysql資料庫
以下網址db4free 是僅提供測試,務必自己要自己備份
db4free
瀏覽器緩存
在index.html新增
1 | <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> |