JSPM

  • Created
  • Published
  • Downloads 61
  • Score
    100M100P100Q79301F
  • License MIT

A hook of iztro。紫微斗数开源库iztro的react钩子函数。

Package Exports

  • iztro-hook
  • iztro-hook/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (iztro-hook) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

📦 iztro-hook

紫微斗数开源库iztro的react钩子函数。

Maintainability Codecov npm Codecov npm GitHub GitHub code size in bytes Package Quality


基于 iztro 实现的 react hook。 用于获取紫微斗数星盘数据,运限数据(大小限,流年,流月,流日,流时等)。详细功能请查看 iztro开发文档

安装 (installation)

npm install iztro iztro-hook -S

你可以用任何你熟悉的包管理软件来安装依赖。

参数 (parameters)

export type IztroInput = {
  birthday: string;
  birthTime: number;
  gender: GenderName;
  birthdayType: 'lunar' | 'solar';
  isLeapMonth?: boolean;
  fixLeap?: boolean;
};

hook 定义 (hook defination)

type useIztro = (input: IztroInput) => {
  astrolabe: FunctionalAstrolabe | undefined;
  horoscope: Horoscope | undefined;
  setHoroscope: (date: string | Date, hour?: number) => void;
}

使用 (how to use?)

hook 只能在 react 组件中使用,如果你的项目不是使用 react 框架开发的,请使用 iztro 自行封装。

import React from 'react';
import { useIztro } from 'iztro-hook';

export default App() {
  const { astrolabe, horoscope, setHoroscope } = useIztro({
    birthday: '2000-18-16',
    birthdayType: 'solar',
    birthTime: 2,
    gender: '女',
    fixLeap: true,
  });


  return (
    <>在此绑定数据进行渲染</>
  );
}

如果你想了解更多关于紫微斗数的知识或者本开源库的信息,可以查看 iztro。如果好用记得给我一个⭐️鼓励哦~