? ???? ?? ??? ?? ????? ?? ?????? ???? ?? vue2? ?????. ?? ?? ???? ??? ? ????.
???? ??????? gif? ??? ? ??? ??? ???? ?? ??? ????. ???? ??? ? ???? ??? ? ?????. ?? ???? ????? ???? axios? js ???? ???? ???. ?? ?? ? ???? app.vue? ???? ???. ??? ????:
<template> <p id="app"> <loading v-show="fetchLoading"></loading> <router-view></router-view> </p> </template> <script> import { mapGetters } from 'vuex'; import Loading from './components/common/loading'; export default { name: 'app', data() { return { } }, computed: { ...mapGetters([ 'fetchLoading', ]), }, components: { Loading, } } </script> <style> #app{ width: 100%; height: 100%; } </style>
??? fetchLoading? vuex? ??? ?????. store/modules/common.js?? ?? ??? ?????.
/* 此js文件用于存儲(chǔ)公用的vuex狀態(tài) */ import api from './../../fetch/api' import * as types from './../types.js' const state = { // 請求數(shù)據(jù)時(shí)加載狀態(tài)loading fetchLoading: false } const getters = { // 請求數(shù)據(jù)時(shí)加載狀態(tài) fetchLoading: state => state.fetchLoading } const actions = { // 請求數(shù)據(jù)時(shí)狀態(tài)loading FETCH_LOADING({ commit }, res) { commit(types.FETCH_LOADING, res) }, } const mutations = { // 請求數(shù)據(jù)時(shí)loading [types.FETCH_LOADING] (state, res) { state.fetchLoading = res } }
?? ?? ??? ??? ????.
<template> <p class="loading"> <img src="./../../assets/main/running.gif" alt=""> </p> </template> <script> export default { name: 'loading', data () { return {} }, } </script> <!-- Add "scoped" attribute to limit CSS to this component only --> <style scoped> .loading{ position: fixed; top:0; left:0; z-index:121; width: 100%; height: 100%; background: rgba(0,0,0,0.3); display: table-cell; vertical-align: middle; text-align: center; } .loading img{ margin:5rem auto; } </style>
????? fetch/api.js? ???? axios? ?? ?? ???? ?????. ??? ????
// axios的請求時(shí)間 let axiosDate = new Date() export function fetch (url, params) { return new Promise((resolve, reject) => { axios.post(url, params) .then(response => { // 關(guān)閉 loading圖片消失 let oDate = new Date() let time = oDate.getTime() - axiosDate.getTime() if (time < 500) time = 500 setTimeout(() => { store.dispatch('FETCH_LOADING', false) }, time) resolve(response.data) }) .catch((error) => { // 關(guān)閉 loading圖片消失 store.dispatch('FETCH_LOADING', false) axiosDate = new Date() reject(error) }) }) } export default { // 組件中公共頁面請求函數(shù) commonApi (url, params) { if(stringQuery(window.location.href)) { store.dispatch('FETCH_LOADING', true); } axiosDate = new Date(); return fetch(url, params); } }
?????. ????? ???? ???? gif ???? ?????? ???? ???? ?????.
vue.js ?? ????? ??? ?? vue.js ???? ?? ????? Vue.js ????? ???? ?? ????? ???? ?????.
? ?? Vue ?? ????? ??? ?? ?? "Vue Practical Tutorial"? ?????.
? ??? ?? ???? ?? ??? ?????. ??? ??? ?? ????.
?? ??:
jQuery? ???? animate.css ???(??? ????)
? ??? vue2?? ??? ?? ?? ?? ???? ???? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

vue2? vue3? ?????? ?? ?? ?? ?????? ?? vue2? ?? ?? beforeCreate=>created=>beforeMount=>mounted=>beforeUpdate=>updated=>beforeDestroy=>destroyed vue3? ?? ?? setup=>onBeforeMount= >onMounted=> onBeforeUpdate=>onUpdated=>onBeforeUnmount=&g

Vue?? ??? ?? ??: AxiosorFetch? Vue ???? ??? ??? ???? ?? ?? ???? ?????. ??? ??? ??? ??? ???? ?? ???? ? ?????. Vue?? ?? ???? ? ?? ??? Axios? Fetch???. ? ????? ? ??? ???? ???? ???? ? ??? ?? ? ?? ?? ??? ?????. Axios? ????? Node.js?? ???? Promise ?? HTTP ????????.

diff ????? ??? ??? ?? ??? ???? ???? ??????, ??? ???? ???? ??? ??? ????. ???? diff ????? ?? ??? ?? ???? ?? ?? vue2? diff ????? ?? ?? ??? ??? ????. ??? ?? ????!

??? ?? ????? ???? ? ???? ?? ???? ?? ???? ??? ??? ???? ?? ??? ?? ????. ?? ????? ????? ????? ????? ?? ??? ?????. Vue ???????? ?? ?? ??? ???? ??? ??? ????. 1??: Vue ???? ?? ?? Vue ?????? ??? ? ?? loading??? Vue ????? ??? ? ????. ??????? ?? ? ?? ??? ???? ???.

? ??? Vue ??? ???? Vue2 ? Vue3?? 404 ?????? ???? ??? ?? ?????. ??? ??? ????.

Vue?? ??? ?? ??? ???? ?? Vue ????? ??? ?? ??? ???? ?? ???? ?? ?????. ?? ?? ??? ????? ???? ?? ??? ???? ?? ???? ???? ??? ??? ???? ? ????. ? ????? Vue?? ?? ?? ??? ???? ??? ???? ?? ?? ??? ?????. ?? Loading ?? ?? ??? ?? ?? Loading ?? ??? ???? ???. ? ?? ??? ??? ? ????.

Vue ??????? ????? ???? ??? ?? ?????: Axios ?? ?? ??: Vue ??????? ????? ???? ??? ?? ?????: Axios ?? ?? ??: Vue ???? ??? ??? ???? ?????. Vue?? ????? ???? ??? ?? ?????? Axios? ???? ???? ?? API? ??? ??? ??? ?? ????? ???? ???? ??? ?? ?????. ? ????? Axios ?? ??? ? ?? ???? ?????? ????? ??? ???? ??? ??? ? ??? ?? ?? ??? ?????. ????

? ??? vue2? ?? ?? ??? ?????. ?? vue2?? ??? ??? ?? ??? ???? ??? ?? ?????. ?? ?? ??? ??? ???? ?? ?? ???? ??? ??? ????.
