packago javascript module
This commit is contained in:
58
readme.md
58
readme.md
@@ -2,9 +2,63 @@
|
||||
|
||||
“中国家庭称谓计算器”为你避免了这种尴尬,只需简单的输入即可算出称谓。输入框兼容了不同的叫法,你可以称呼父亲为:“老爸”、“爹地”、“老爷子”等等,方面不同地域的习惯叫法。快捷输入按键,只需简单的点击即可完成关系输入,算法还支持逆向查找称呼哦~!
|
||||
|
||||
借助这套算法结合react native开发的APP:
|
||||
借助这套算法结合react native开发的APP: [http://passer-by.com/relationship/app.html](http://passer-by.com/relationship/app.html)
|
||||
|
||||
http://passer-by.com/relationship/app.html
|
||||
|
||||
## 一、下载 & 安装
|
||||
|
||||
该 Javascript 库 / 模块可以用于前端也可以用于后端 Nodejs 中。
|
||||
|
||||
1. 直接下载dist/relationship.min.js,然后使用 `<script>`标签引入,可以得到全局的方法 `relationship`.
|
||||
2. 使用 npm 进行包管理,具体为:
|
||||
|
||||
> **npm install relationship.js**
|
||||
|
||||
然后使用 `require` 引入模块
|
||||
|
||||
```js
|
||||
var relationship = require("relationship.js");
|
||||
```
|
||||
|
||||
|
||||
## 二、使用
|
||||
|
||||
使用很简单,只有一个 API 方法 `relationship(options)`.
|
||||
|
||||
```js
|
||||
var options = {text:'儿子的爸爸的妈妈',sex:1};
|
||||
relationship(options);
|
||||
```
|
||||
|
||||
另外,参数`options`结构为:
|
||||
|
||||
```js
|
||||
var options = {
|
||||
text:'',
|
||||
sex:-1,
|
||||
type:'default', //为'chain'时,reverse无效
|
||||
reverse:false
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
## 三、开发 & 贡献
|
||||
|
||||
```sh
|
||||
# 安装开发依赖
|
||||
npm install
|
||||
|
||||
# build 模块: 将 relationship 打包压缩
|
||||
npm run build
|
||||
|
||||
# 执行测试用例(可以在tests/test.js中完善测试用例)
|
||||
npm test
|
||||
```
|
||||
|
||||
当然也可以直接浏览器打开 `index.html` 来在查看网页demo。
|
||||
|
||||
|
||||
## 四、其他
|
||||
|
||||
他们都在用:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user