2025年4月22日 星期二

React class & style(3)

1.先清除index.css,換成
.parent{
    color:  rgb(147, 60, 229);
}

.child{
    color: rgb(232, 150, 27);
    background-color: rgb(234, 78, 11);
}

2.接著回到App.jsx加入class
const Child = () => {
  return (
    <>
      <h3 className="child">Child Component</h3>
    </>
  )
}

const App = () => {
  return (
    <>
      <h2 className="parent">App Component</h2>
      <Child />
      <Child />
    </>
  )
}
export default App
React的class必須寫成className
3.修改Child component加入inline styles
const Child = () => {
  return (
    <>
      <h3 className="child" style={{
        backgroundColor: '#BBFFFF'
      }}>Child Component</h3>
    </>
  )
}
原css中如有-則使用小駝峰(lower camel case)
inline styles優先度大於class
參考資料
Adding styles
React JS 19 Full Course 2025 | Build an App and Master React in 2 Hours

React Component(2)

React Component寫法有蠻多種的
以下是個人覺得比較簡潔的
1.將App.jsx內容先全部清除改成
const App = () => {
  return (   
      <h2>App Component</h2>   
  )
}
export default App
完成第一個Component了
2.接著新增一個Child Component
const Child = () => {
  return (
    <>
      <h3>Child Component</h3>
    </>
  )
}
3.在App Component中使用多個Child Component
const App = () => {
  return (
    <>
      <h2>App Component</h2>
      <Child />
      <Child />
    </>
  )
}
export default App
表示Component可重複使用
特別注意 Component第一個字為大寫
參考資料
Your First Component
React JS 19 Full Course 2025 | Build an App and Master React in 2 Hours

2025年4月21日 星期一

React VS Code + Vite + React開發(1)

React過去有幾個地方令人詬病,React 19改善了許多
目前在寫法上也改進了許多,本篇開始紀錄開發過程
開啟VS Code > Terminal
npm create vite@latest
Project name:
.(於目前開啟的資料夾)
Select a framework:
react(或輸入想要的名稱)
Select a variant:
javascript(或擅長的開發方式)
檢查一下package.json > dependencies > react 版本是不是19.0.0
npm install
npm run dev
點開網頁完成了第一次建立
如何建立發佈檔案
npm run build 
檔案會在dist下
參考資料
Build a React app from Scratch
React JS 19 Full Course 2025 | Build an App and Master React in 2 Hours

2025年4月14日 星期一

IIS At least one other site is using the same HTTPS binding and the binding is configured

一台Server IIS使用多網站憑證問題
At least one other site is using the same HTTPS binding and the binding is configured
解決方式
勾選Require Server Name Indication
中文版請參考下方參考資料
參考資料
IIS 多站台使用 HTTPS 憑證的設定方式

2025年4月1日 星期二

npm : 因為這個系統上已停用指令碼執行,所以無法載入

1.開啟PowerShell
2.執行
get-executionpolicy
3.如為Restricted執行
set-executionpolicy remotesigned
4.如有例外改執行
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
參考資料
VSCode 執行 npm install 失敗