Posts
父組件傳遞資料在子組件偵測應用
(CustomSelect.vue)子組件要偵聽父組件(App.vue)來的props,使用watch監聽,來變更子組件的數據。(備註:computed也可以)
父組件 App.vue <template> <div id="app"> 父組件: <el-input-number v-model="parentSelectedValue" @change="handleChange" :min="1" :max="10" label="描述文字"></el-input-number> <custom-select :parentSelectedValue="parentSelectedValue" :title="title" @returnSelectedChange="getSelectedValue"></custom-select> 子組件,變更時選擇的數值:{{ selectedValue }} </div> </template> <script> import customSelect from "./components/CustomSelect.vue"; export default { name: "App", components: { customSelect, }, data() { return { selectedValue: null, title: "縣市", parentSelectedValue: null, }; }, methods: { getSelectedValue(val) { this.selectedValue = val; }, handleChange(value) { this.parentSelectedValue = value; }, }, }; </script> <style></style> 子組件 CustomSelect.vue <template> <div> <b>{{ title }}:</b> <el-select v-model="value" placeholder="請選擇縣市" @change="selectedChange"> <el-option v-for="item in options" :key="item.
Posts
建立 Vue.js 前端專案
安裝 Node.js 安裝 Vue CLI npm install -g @vue/cli 創建 Vue.js 專案 vue create my-project 啟動 Vue.js 專案 cd my-project npm run serve
Posts
Vue Provide 和 Inject
原本要傳遞三層
App -> FirstLayer -> SecondLayer -> ThirdLayer
可使用Provide和Inject提供跨多層組件傳遞數據的方式
App -> ThirdLayer
App.vue <template> <div id="app"> <div :class="theme"> <button @click="changeFontSize">"第一層"字型變大</button> <FirstLayer ref="first" /> </div> </div> </template> <script> import FirstLayer from "./components/FirstLayer"; export default { name: "App", data() { return { myName: "ming", theme: "theme" }; }, provide() { return { myName: this.myName, changeBgColor: this.changeBgColor }; }, components: { FirstLayer }, methods: { changeBgColor() { console.log("changeBgColor"); this.theme = "dark-theme"; }, changeFontSize() { this.
Posts
Git Tutorial
Git設定 查看設定 git config –list
設定帳號 git config –global user.name “hezhengmin”
設定信箱 git config –global user.email “zhengmin099@gmail.com”
Git基本用法 建立Repository git init
複製他人專案 git clone https://github.com/hezhengmin/Minesweeper.git
檢查狀態 git status
查詢記錄 git log
新增全部的檔案 git add .
git add –all
全部修改提交 git commit -am “modified”
推送到你的遠端 git push origin master
遠端主機分支master更新到本地主機 git pull origin master
刪除檔案 git rm “1. Two Sum.cpp”
Git分支用法 建立新branch並切換過去 git checkout -b <branch名稱>
查看電腦上的branch(按q可以離開) git branch
查看所有的branch(包含remote) git branch -a
Posts
Postman-儲存JwtToken為全域變數
1. 新增script const resp = pm.response.json(); pm.environment.set("jwtToken", resp.jwtToken) 程式回傳jwt token 2. 新增JWT變數 3. Request API上加入Token (Authorization) 4. Request API上加入Token (Header) 參考 Postman 儲存 API 變數 JWT Token 驗證資訊
Posts
建立網站
安裝 Hugo 官方提供 Hugo安裝路徑 設定環境變數 創建新站點 確認有無安裝hugo hugo version 建立 hugo new site quickstart 添加主題 cd quickstart git init git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke 添加一些內容 hugo new posts/my-first-post.md 例如 D:\Github\Hugo\quickstart> hugo new posts/202303191040.md 啟動 Hugo 服務器 hugo server -D 構建靜態頁面 hugo -D cd public file_server . git init git remote add origin https://github.com/hezhengmin/hezhengmin.github.io.git git add -A git commit -m "init site" git push origin master 開啟http://localhost:1313/ 測試網站 PS D:\Github\Hugo> cd quickstart PS D:\Github\Hugo\quickstart> hugo server -D 參考 https://gohugo.