node 大写_大写Node.js模块
node 大寫
Today, let's see a third party module that helps us in working with upper-case letters without necessarily typing them in upper-case in our source code.
今天,讓我們看一個第三方模塊,它可以幫助我們處理大寫字母,而不必在源代碼中以大寫字母鍵入它們。
You may find it useless! But it's very important.
您可能會發(fā)現(xiàn)它沒有用! 但這很重要。
For example, you may have a form where you require your users to fill in upper-case letters only. You may wish to add a function where any typed in the letter appears in upper-case even though typed in lower-case from the keyboard.
例如,您可能有一個表單,要求您的用戶僅填寫大寫字母。 您可能希望添加一個功能,即使從鍵盤輸入小寫字母,字母中的任何字母都以大寫形式顯示。
Like said before, Node modules are like libraries which help us perform specific tasks. Node.JS is always considered powerful because it has a very large ecosystem of third-party modules.
如前所述,Node模塊就像是可以幫助我們執(zhí)行特定任務的庫。 Node.JS一直被認為是功能強大的,因為它具有非常龐大的第三方模塊生態(tài)系統(tǒng)。
The upper-case module is a third-party module built by some experts to help us.
大寫模塊是一些專家構建的第三方模塊,可以幫助我們。
Take Note! You should have Node.js installed in your PC.
做記錄! 您應該在PC中安裝了Node.js。
With Node.js already up and running, let's get started.
在Node.js已經(jīng)啟動并運行的情況下,讓我們開始吧。
Now, let's get started.
現(xiàn)在,讓我們開始吧。
First of all, install the upper-case module by typing npm install upper-case via the command line.
首先,通過在命令行中鍵入npm install upper-case來安裝大寫 模塊 。
Wait for a while as it downloads.
NB: Internet required!
等待下載。
注意:需要互聯(lián)網(wǎng)!
Take note that only third party modules are installed via command line unlike built in modules which comes along with the node.js environment when downloaded...
請注意,不同于第三方模塊在下載時隨Node.js環(huán)境一起提供的內(nèi)置模塊,僅通過命令行安裝了第三方模塊。
Let's look at a basic use of the upper-case module.
讓我們看一下大寫模塊的基本用法。
We'll create an http server that will output hello world in capital letters but written in small letters in the source code.
我們將創(chuàng)建一個http服務器,該服務器將以大寫字母輸出問候世界,但在源代碼中以小寫字母書寫。
Open a text editor and type the following code and save it with the file name app.js:
打開一個文本編輯器,輸入以下代碼,并將其保存為文件名app.js :
var http = require('http'); // includes the http module var uc = require('upper-case'); // include the upper-case module http.createServer(function (req, res) {res.writeHead(200, {'Content-Type': 'text/html'});res.write(uc("hello world!")); // assign the upper-case moduleres.end(); }).listen(8080); // port numberNote: The file should be saved in your default Node.js directory.
注意:該文件應保存在默認的Node.js目錄中。
Initiate the JavaScript file at the console by typing node app.js
通過鍵入節(jié)點app.js在控制臺上啟動JavaScript文件
Take Note! : Your command line directory should be same with Node.js module directory.
做記錄! :您的命令行目錄應與Node.js模塊目錄相同。
Finally, open your browser and navigate to http://localhost:8080
最后,打開瀏覽器并導航到http:// localhost:8080
Thanks for coding with me. Your comments are most welcome.
感謝您與我一起編碼。 非常歡迎您發(fā)表評論。
翻譯自: https://www.includehelp.com/node-js/upper-case-node-js-module.aspx
node 大寫
總結
以上是生活随笔為你收集整理的node 大写_大写Node.js模块的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 下载补丁怎么跳出的都是黄色网址啊
- 下一篇: YYSSW的完整格式是什么?