iT邦幫忙

2021 iThome 鐵人賽

DAY 17
0
Modern Web

Vue 3 請你幫我做一個網站好嗎 (っಠ‿ಠ)っ系列 第 18

Day18 - 學了一點點 vuex

檔案 vuex 說明
store/index.js state 像元件裡 data() 的功能,存資料用
getters 像元件裡 computed() 的功能,可以使用 state 裡的資料做運算

.vue 檔要取得 store 裡的資料就需要透過 computed 向 store 取得資料

檔案 vuex 說明
.vue computed:{yourComputedFun() {return this.$store.state.yourStateDataName} 取用 store/index.js 裡的 state 資料
...mapState([]) 一次取用多個 store/index.js 裡的 state 資料
this.$store.getters.yourGettersDataName 取用 store/index.js 裡的 getters 資料
...mapGetters([]) 一次取用多個 store/index.js 裡的 getters 資料

今天先理解到這邊~如果上述內容有出入,希望路過的朋友能俠義挺身糾正,感恩的心(っಠ‿ಠ)っ


上一篇
Day17 - 上架後臺的商品列表頁,今天只鋪了 template
下一篇
Day19 - vue cli 使用 bootstrap modal
系列文
Vue 3 請你幫我做一個網站好嗎 (っಠ‿ಠ)っ19
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言