安装第三方库依赖文件
npm install opencc-js
引用
const OpenCC = require('opencc-js');
定义
// Convert Traditional Chinese (Hong Kong) to Simplified Chinese (Mainland China)
const converter = OpenCC.Converter({ from: 'hk', to: 'cn' });
console.log(converter('漢語')); // output: 汉语
From GitHub:https://github.com/nk2028/opencc-js