1.方法useMessage为封装的Element-plus中的message
import {ref,reactive,toRefs,onMounted} from 'vue'
import { useMessage } from './tools'
export function useLoading (value:boolean):any {//多个loading方法
const state = reactive<boolean []>([])
const index = 0
state[index] = state[index] || value
const loadingMessage = (newState:boolean,type?:string,message?:string):boolean => {
if(type&&message){
useMessage(type,message)
return state[index] = newState
}else{
return state[index] = newState
}
}
return [...toRefs(state),loadingMessage]
}