Vue定时器清理

直接在需要定时器的方法或者生命周期函数中声明并销毁 1 2 3 4 5 6 7 8 9 10 11 12 13 14 export default{ methods:{ getGameList(){ const timer = setInterval(()=>{ //需要做的事情 console.log(

Vue中Axios请求全局配置

文件引入 1 2 import Vue from 'vue' import axios from 'axios' 全局参数 1 Vue.prototype.$http = axios 请求头Header 1 2 3 4 5 6 7 8 9 10 11 axios.interceptors.request.use(function (config) { config.headers['Content-Type'] = 'application/json;charset=UTF-8' const token = localStorage.getItem('token') const TGC = getCookie('TGC') if (TGC) { config.headers.Authorization = TGC } else if (token) { config.headers.Authorization = token