guide:frontend-dev
**這是本文件的舊版!**
前端開發指南
圖片
- snippet.html
<img src="pic_1x.jpg" srcset="pic_1x.jpg 1x, pic_2x.jpg 2x" />
lazy import
- snippet.jsx
import React, { useState, createElement } from 'react'; import MessageList from './MessageList'; import MessageInput from './MessageInput'; import ErrorBoundary from './ErrorBoundary'; const Channel = () => { const [emojiPickerEl, setEmojiPickerEl] = useState(null); const openEmojiPicker = () => { import(/* webpackChunkName: "emoji-picker" */ './EmojiPicker') .then(module => module.default) .then(emojiPicker => { setEmojiPickerEl(createElement(emojiPicker)); }); }; const closeEmojiPickerHandler = () => { setEmojiPickerEl(null); }; return ( <ErrorBoundary> <div> <MessageList /> <MessageInput onClick={openEmojiPicker} /> {emojiPickerEl} </div> </ErrorBoundary> ); };
PDF 頁面開發
- 可以在後端用 puppeteer 的
.pdf()
來輸出,文件可見 github。 - 前端建議長度單位直接用 cm,設計圖也是。
options
- snippet.javascript
{ format: 'A4', printBackground: true, timeout: 300000, displayHeaderFooter: true, headerTemplate: '', footerTemplate: ` <div class="page-footer" style="width:100%; text-align:center; font-size: 8px; color:#999999; background-color:#fcfcfc;"> <span class="pageNumber"></span> </div> `, margin: { bottom: '15mm' }, pageRanges: '2-', }
guide/frontend-dev.1656068231.txt.gz · 上一次變更: 2024/12/22 21:17 (外部編輯)