UNPKG

vite-uni-dev-tool

Version:

vite-uni-dev-tool, debug, uni-app, 一处编写,到处调试

22 lines (17 loc) 370 B
import { watchEffect } from "vue"; type UseErrorOptions = { emitListener: boolean; }; export function useError(message: string, { emitListener }: UseErrorOptions) { const emit = () => { throw new Error(`[VueJsonPretty] ${message}`); }; watchEffect(() => { if (emitListener) { emit(); } }); return { emit }; }