niucloud/uni-app/hooks/useCaptcha.ts
全栈小学生 8a600afd4f 更新uni-app
2023-05-20 18:12:41 +08:00

26 lines
572 B
TypeScript

import { getCaptcha } from '@/api/system'
import { ref } from 'vue'
interface formData {
captcha_code: string,
captcha_key: string
}
export function useCaptcha(formData: formData) {
const image = ref('')
const refresh = async ()=> {
try {
const res:AnyObject = await getCaptcha()
formData.captcha_key = res.data.captcha_key
formData.captcha_code = ''
image.value = res.data.img.replace(/\r\n/g, '')
} catch (e) {
}
}
return {
image,
refresh
}
}