currentConfig.ts 389 B

1234567891011121314151617181920
  1. import type { RootState } from "@/store/store";
  2. // 为了解决在组件中获取值时typescript提示可能为null的情况
  3. export function selectCurrentCurrency(
  4. state: RootState
  5. ) {
  6. const currency = state.currentConfig.currentCurrency;
  7. if (!currency) {
  8. throw new Error(
  9. "currentCurrency is not initialized"
  10. );
  11. }
  12. return currency;
  13. }