当前位置:网站首页>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)
边栏推荐
- Electric heating neck pillow chip-dltap703sc
- Aircraft collision detection
- Set the arc button to be displayed in the middle
- [yuntu said] 249 mobile application security service - app's physical examination center, comprehensive testing, safe on the road!
- The hero of the aircraft war comes out with bullets
- ERROR 1366 (HY000): Incorrect string value: ‘\xE8\xB5\xB5\xE9\x9B\xB7‘ for column ‘s_ name‘ at row 1
- Login page tablelayout
- Using Jieba and pyhanlp tools to extract keyword words and sentences
- INSUFFICIENT_ ACCESS_ ON_ CROSS_ REFERENCE_ ENTITY APEX / SALESFORCE
- 网红RGB镜子灯触摸芯片-DLT8S15B-杰力科创
猜你喜欢

图文结合,完美解释MySQL逻辑备份的实现流程

Uni app label jump

Netred RGB mirror light touch chip-dlt8s15b-jericho

JDBC-MySql 02 数据访问和DAO模式

商品名称模糊搜索:

Build a simple knowledge question and answer system

浅谈JVM(面试常考)

How to realize the full-text content retrieval of word, PDF and txt files?

Visual studio code installation tutorial (super detailed)

LED学习护眼台灯触摸芯片-DLT8T10S-杰力科创
随机推荐
Aircraft collision detection
filebeat.yml配置文件关于多个服务的配置问题
Filebeat.yml configuration file about the configuration of multiple services
飞机大战英雄出场加子弹实现
Hbuilder submission code
Alibaba architects spent 280 hours sorting out 1015 pages of distributed full stack pamphlets to easily start the distributed system
商品评论信息与评论信息分类
pygame飞机大战游戏背景实现
MySQL 02 初体验
低噪负离子风扇触摸IC
Led with fan eye protection learning table lamp touch chip-dlt8s12a
Mode= "widthfix" attribute in image tag
Use mobaxtermto establish a two-tier springboard connection
V-bind and V-for
Baidu map eagle eye track service
Hash、Set、List、Zset、BitMap、Scan
Arrays and objects in JS
Wechat applet obtains mobile number
这样的API网关查询接口优化,我是被迫的
Modify placeholder style in input