
loading 開關
預設 loading 開關為 true,如想關閉 loading 可在 nuxt.config.js 設定
1 2 3
| export default { loading: false, };
|
修改 loading 樣式
nuxt.config.js
1 2 3 4 5 6
| export default { loading: { color: 'blue', height: '5px', }, };
|
客製 loading
在 components 目錄新增一個 loading.vue
1 2 3 4 5
| <template lang="html"> <div class="loading-page" v-if="loading"> <p>Loading...</p> </div> </template>
|
1 2 3 4 5 6 7 8 9 10 11 12 13
| export default { data: () => ({ loading: false, }), methods: { start() { this.loading = true; }, finish() { this.loading = false; }, }, };
|
1 2 3 4 5 6 7 8 9 10 11 12 13
| .loading-page { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.8); text-align: center; padding-top: 200px; font-size: 30px; font-family: sans-serif; z-index: 999; }
|
在 nuxt.config.js 設定 loading 的組件
1 2 3
| export default { loading: '~/components/loading.vue', };
|
點擊開關 loading
可以從 this.$nuxt 的物件,去抓 $loading,$loading 就是 components/loading.vue 的組件
1
| <button @click="openLoading">loading</button>
|
1 2 3 4 5 6 7 8 9
| methods: { openLoading() { this.$nuxt.$loading.start();
setTimeout(() => { this.$nuxt.$loading.finish(); }, 2000); } },
|
🚀線上課程分享
線上課程可以加速學習的時間,省去了不少看文件的時間XD,以下是我推薦的一些課程
想學習更多關於前後端的線上課程,可以參考看看。
Hahow 有各式各樣類型的課程,而且是無限次數觀看,對學生或上班族而言,不用擔心被時間綁住
如果你是初學者,非常推薦六角學院哦!
剛開始轉職也是上了六角的課,非常的淺顯易懂,最重要的是,隨時還有線上的助教幫你解決問題!
Udemy 裡的課程非常的多,品質普遍不錯,且價格都滿實惠的,CP值很高!
也是很多工程師推薦的線上課程網站。