当前位置:网站首页>npm 基本使用
npm 基本使用
2022-07-27 16:20:00 【敢问】
1、安装
- npm是一个全世界范围内模块的分享社区,可以免费使用这个社区内别人开发的模块。
只关心怎么使用,不用关心如何封装的,因为他们在封装的时候也有可能在引入其他的模块
2、使用
- 打开官网 在搜索框内部查询你需要模块的关键字
比如让1234567智能转换为大写的 搜“大写”
因为在安装NodeJS的时候已经安装了npm包管理器了,所以就可以直接使用;比如我们找到了一个nzh的模块,此时需要使用npm命令进行安装npm install nzh
此时参考提供的API进行使用 nzh 参考文档

var Nzh = require("nzh");
console.log(Nzh.cn.encodeS(100111))// 转中文小写
console.log(Nzh.cn.encodeB(100111))// 转中文大写
console.log(Nzh.cn.encodeS(1.23456789e+21))// 科学记数法字符串
console.log(Nzh.cn.toMoney(100111.11))// 转中文金额
小案例 日期转换
var http = require("http")
var solarLunar = require('solarLunar')
var server = http.createServer(function (req,res) {
//字符集
res.setHeader("Content-type","text/html;charset=UTF8")
let arr = req.url.match(/\/(.+)\/(.+)\/(.+)$/)
let $1 = arr[1];
let $2 = arr[2];
let $3 = arr[3];
console.log($1,$2,$3)
var gl = solarLunar.solar2lunar($1,$2,$3) //输入的日子为公历
var nl = solarLunar.lunar2solar($1,$2,$3) //输入的日子为农历
res.end(`<h1>今年是${gl.cYear}年${gl.cMonth}月${gl.cDay}${gl.animal}年</h1>`)
})
server.listen(3000)
边栏推荐
- Build a simple knowledge question and answer system
- TS learning notes interface
- PyGame aircraft war game background implementation
- EN 1155 building hardware swing door opener - CE certification
- INSUFFICIENT_ ACCESS_ ON_ CROSS_ REFERENCE_ ENTITY APEX / SALESFORCE
- js中的函数与DOM获取元素和事件属性的使用
- V-bind and V-for
- Run the uniapp to the mobile phone (real machine debugging)
- MySQL 05 存储过程
- Baidu map eagle eye track service
猜你喜欢
随机推荐
Modify placeholder style in input
Use mobaxtermto establish a two-tier springboard connection
Examples of map search
JS tool - Cookie simple encapsulation
The song of the virtual idol was originally generated in this way!
ValueError: Found input variables with inconsistent numbers of samples: [80019456, 26673152]【报错】
Visual studio code installation tutorial (super detailed)
迷你洗衣机触摸芯片-DLT8MA12TS-杰力科创
Aircraft collision detection
Have you ever stumbled on MySQL's order by
如何实现Word、PDF、TXT文件的全文内容检索?
Hash、Set、List、Zset、BitMap、Scan
How to realize the full-text content retrieval of word, PDF and txt files?
Functions in JS and the use of DOM to obtain elements and event attributes
Use ETL tools for data migration in salesforce project
Mini washing machine touch chip dlt8ma12ts Jericho
The combination of text and words perfectly explains the implementation process of MySQL logical backup
Uploading and downloading of files
Vue uses keep alive to realize page caching
Product name fuzzy search:









