pinyinlite icon indicating copy to clipboard operation
pinyinlite copied to clipboard

pinyinlite is not a function

Open RaoMcGrady opened this issue 7 years ago • 7 comments

我在RN 项目中应用了该库,不知道为什么? 运行代码上报这个方法错误,

const pinyinlite = require('pinyinlite'); var keyPinyin = pinyinlite('第三方',true); 是我那出问题了么

RaoMcGrady avatar Jun 05 '17 08:06 RaoMcGrady

你是通过 npm 安装的吗?

breezewish avatar Jul 24 '17 06:07 breezewish

我遇到了同样的问题,报错:Object is not a function。是通过npm安装的,RN版本0.44.3。

chenchen1008 avatar Sep 04 '17 08:09 chenchen1008

我在 RN 上也遇到了同样的问题,请求模块返回一个空对象 我是通过 yarn 安装的,我想应该和包管理器没有关系

require('pinyinlite') // => {}

baijunjie avatar Sep 19 '17 05:09 baijunjie

我找到了问题所在,RN 中的包好像必须包含 index.js 这个文件,我创建了一个 index.js 的空文件,模块就加载正常了,不清楚为什么会这样。

这个模块对繁体中文处理比较好,所以希望作者能尽快修复这个模块

baijunjie avatar Sep 19 '17 06:09 baijunjie

import pinyinlite from 'pinyinlite/index_common' or import pinyinlite from 'pinyinlite/index_full';

gitH101 avatar Oct 24 '17 01:10 gitH101

下载源代码

var dict = require('./dict_full.js'); var pinyinlite = require('./pinyin.js')(dict);

这样也能正常导入

neequ avatar Nov 17 '17 18:11 neequ

楼上几位打大侠厉害了, 我找了两三天了。 终于解决了

EliteCRM avatar May 17 '18 07:05 EliteCRM