未看https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw
有一點比較特別的是,如果將 \ 放在字串的最後,會導致當成判斷字串的引號被當成跳脫序列而產生錯誤。
未看https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw
https://zhuanlan.zhihu.com/p/675860025
1.过去改变不了,未来展望不到,现在凑合着过吧。
2.没有什么水逆 ,你只是在给自己的好运蓄力。
3.大家可以放肆的去热爱生活的同时,也更加热爱自己,当你热爱生活的时候,我觉得生活也会更加的热爱你,让每天都可以成为幕圆满的每一天。
4.没有人能够决定你的选择是对是错。
5.我很幸运,把自己的热爱变成了事业。
6.选择音乐从来不是一件勇敢的事,坚持才是。
7.我有自己的坚持,有自己的追求,也有自己想要的更多的东西,不是我贪心,只是我想获得更多的尝试。
8.一定要快乐,要幸福,做自己想做的,要自由。
9.我觉得自己现在就是一颗想燃烧,但是燃烧了一半就是半燃烧的一颗恒星!
10.未到结局,焉知生死,不到最后,你永远不知道自己能创造出什么机会和可能。
11.灯光老师麻烦把灯关一下谢谢,这个时候不需要有我们有她们就够了。
12.也许那是最后无悔与忠贞,才是成长的真谛吧。
13.难熬的时候终归是难熬的,过了这段时间会是一片彩虹。
14.我不怕熬夜,不怕失败,我可以重来。
15.什么时候不满意自己,那就打碎不满意的自己。
16.我希望每一个年轻人在寻找自己梦想的同时,都不要只停留在自己的想象里。
17.枯燥的过程机械的反复练习,才是你走进自己心之所向的唯一途径。
18.我摔倒了就爬起来,爬起来下次接着摔呗,下一次要更华丽的摔到。
19.年轻人正处在一个积极接触外界的一个阶段,被误解、否定、偏见在所难免。但是一个年轻人想要证明自己,想要获得认可,除了不被个人情绪打倒,更重要的是学习如何成为一个更好的大人。
20.我觉得做什么事儿都是要有野心的,要给自己定一个也许攀登都攀登不到的一个高度。如果你连给自己设立目标的勇气胆量都没有,我觉得真的是,搬砖吧。
21.其实有的时候如果你可以简单的伸出一只援手,在我们生活的这样的一个环境中,当我们真的感受到别人的爱的同时,我们也要自己主动的敞开心扉去爱身边的一个人,我觉得如果这样的话,可以让整个环境可以变得越来越暖。
22.现在回想起这段时光,其实我记得 其实不是辛苦其实我觉得更多的是对自己的感谢,因为选择了一条更难的路,并锻炼出了更结实的羽翼。
23.多经历一些坏事才是好事,开心的日子是短暂的,痛苦的日子是永恒的。
24.一条自由的鱼,想去哪就去哪,至少在我这个年龄,我有底气说这个话,我是自由的。
25.我们之中有的人会在外界的压力下变得畏首畏尾也看的人会因自我的迷茫而放弃自己热爱的方向,青年虽竟满力量,也充满着苦恼,就像不同年龄段之间的群体,他们很难相互理解每个人在成长的过程中都会经历自身和外界的强烈碰撞。
https://www.youtube.com/watch?v=uP6KTupfyIw
https://github.com/scps960740/Webpack-crash-course-2021-bruceFE/blob/master/webpack.config.js
https://webpack.js.org/concepts/
To get started you only need to understand its Core Concepts:
Asset Modules allow one to use asset files (fonts, icons, etc) without configuring additional loaders.
Prior to webpack 5 it was common to use:
raw-loader to import a file as a stringurl-loader to inline a file into the bundle as a data URIfile-loader to emit a file into the output directoryAsset Modules types replace all of these loaders by adding 4 new module types:
asset/resource emits a separate file and exports the URL. Previously achievable by using file-loader.asset/inline exports a data URI of the asset. Previously achievable by using url-loader.asset/source exports the source code of the asset. Previously achievable by using raw-loader.asset automatically chooses between exporting a data URI and emitting a separate file. Previously achievable by using url-loader with asset size limit.When using the old assets loaders (i.e. file-loader/url-loader/raw-loader) along with Asset Modules in webpack 5, you might want to stop Asset Modules from processing your assets again as that would result in asset duplication. This can be done by setting the asset's module type to 'javascript/auto'.
**補充 devtool: 'source-map'可以讓build出來的檔案多出xxxx.map,這會在瀏覽器看source時可以看到非production被編譯過的版本的code,協助debug
build 會把檔案build出來
dev會起server,沒特別設置時抓的是當前目錄資料夾,如果有index.html就會顯示它,它裡面要載入剛build出來的output.js
https://www.youtube.com/watch?v=zqV7NIFGDrQ
https://github.com/scps960740/React-crash-course-2021-bruceFE
https://react.dev/reference/react/hooks
<div name={name} />
父子層自動雙向綁定,不用emit
就像vue的watch with immediate: true
const Home = () => {
useEffect(() => {
// 綁定的事件
return()=>{ // 這個很少用
// 取消綁定的事件
}
}, [watch的變數])
//如果沒有變數,就是只執行最初的一次,後面沒有監聽(感覺這個是比較不正規的做法嗎嗎嗎???)
//[watch的變數可以不只一個
}
**jsx 就像vue裡的template
**只要想在jsx裡用js就要用大括號
例如:
// List.js // 這是個component
const arr = [1, 2, 3]
const List = () =>{
return <div className="list">
{
arr.map(item => <div>{item}</div>)
}
</div>
}
export default List
Using the index as a key when rendering an array in React is generally discouraged for a few reasons:
Stability: Indexes may change if items are added, removed, or reordered in the array. This can lead to unnecessary re-renders and potentially affect component state or cause unexpected behavior.
Performance: React uses keys to efficiently update and reconcile the DOM. When using the index as the key, React may have to re-render more components than necessary, impacting performance.
Component State: If components in the array have internal state or rely on lifecycle methods, using the index as the key can lead to inconsistencies or errors when components are re-ordered or removed.
Instead, it's recommended to use a unique identifier for each item in the array as the key. This ensures stability, improves performance, and helps maintain component state integrity. If the array items don't have a unique identifier, consider adding one or using a library like uuid to generate unique keys.
use uuid package 如下
import { v4 } from "uuid";
const Edit = ({ add, submittingStatus }) => {
const [note, setNote] = useState("");
function noteChange(e) {
setNote(e.target.value);
}
const [date, setDate] = useState("");
function dateChange(e) {
setDate(e.target.value);
}
const [time, setTime] = useState("");
function timeChange(e) {
setTime(e.target.value);
}
// TODO del
console.log(note, date, time);
function addItem() {
submittingStatus.current = true
add(function (prevData) {
return [
{
id: v4(),
note,
date,
time,
},
...prevData,
];
});
}
https://www.npmjs.com/package/json-server
idempotent 的意思是如果相同的操作再執行第二遍第三遍,結果還是跟第一遍的結果一樣 (也就是說不管執行幾次,結果都跟只有執行一次一樣)
根據 HTTP 的規格,GET, HEAD, PUT 和 DELETE 是 idempotent,相同的 Request 再執行一次,結果還是一樣。只有 POST 和 PATCH 不是 idempotent,POST 再執行一遍,會再新增一筆資料,PATCH 則是有不能保證 idempotent 的可能性(徵求例子)。POST 和 PATCH 都不是 idempotent 的操作,這也是為什麼 Github API 裡用 POST 當做 PATCH 的相容取代方案。
另一個 HTTP Methods 特性是”Safe”,這比較簡單,只有 GET 和 HEAD 是 Safe 操作。Safe 特性會影響是否可以快取(POST/PUT/PATCH/DELETE 一定都不可以快取)。而 Idempotent 特性則是會影響可否 Retry (重試,反正結果一樣)。
| Safe? | Idempotent? | |
|---|---|---|
| GET | Y | Y |
| POST | N | N |
| PATCH | N | N |
| PUT | N | Y |
| DELETE | N | Y |
網站應用程式常見弱點解析
https://www.tyrc.edu.tw/data/teach/lecture/%E7%B6%B2%E7%AB%99%E6%87%89%E7%94%A8%E7%A8%8B%E5%BC%8F%E5%B8%B8%E8%A6%8B%E5%BC%B1%E9%BB%9E%E8%A7%A3%E6%9E%90.pdf
Front-end Security that Front-end developers don't know:
https://speakerdeck.com/aszx87410/front-end-security-that-front-end-developers-dont-know?slide=22
https://hackmd.io/@ouob/S1U-2_7y2?utm_source=preview-mode&utm_medium=rec
tool:
https://csp-evaluator.withgoogle.com/