##本地环境安装一个包
示例:npm install express 或者 npm i express。
##全局环境安装一个包
示例:npm install -g express 或者 npm i -g express。
| <!DOCTYPE html> | |
| <html> | |
| <head lang="en"> | |
| <meta charset="UTF-8"> | |
| <title>jQuery Mobile模版页面</title> | |
| <meta name="viewport" | |
| content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> | |
| <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.css"/> | |
| <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> | |
| <script src="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.js"></script> |
| <!DOCTYPE html> | |
| <html> | |
| <head lang="en"> | |
| <meta charset="UTF-8"> | |
| <title>jQuery Mobile模版页面</title> | |
| <meta name="viewport" | |
| content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> | |
| <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.css"/> | |
| <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> | |
| <script src="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.js"></script> |
| function StringBuffer() { | |
| this.__strings__ = new Array(); | |
| } | |
| StringBuffer.prototype.append = function (str) { | |
| this.__strings__.push(str); | |
| return this; | |
| } | |
| StringBuffer.prototype.toString = function () { | |
| return this.__strings__.join(""); | |
| } |
##本地环境安装一个包
示例:npm install express 或者 npm i express。
##全局环境安装一个包
示例:npm install -g express 或者 npm i -g express。
| /** | |
| * | |
| * 线上环境的package.json是不能添加任何注释,该例子仅注释说明字段的含义 | |
| * @url: https://www.npmjs.org/doc/files/package.json.html | |
| * */ | |
| { | |
| "name": "micro-dialog", //包的名称,必填选项 | |
| "version": "0.0.1", //包的版本号,必填选项 | |
| "description": "简易对话框", //包的描述 |
| /*确定当前页面高度和宽度的两个函数*/ | |
| function pageHeight() { | |
| return document.body.scrollHeight; | |
| } | |
| function pageWidth() { | |
| return document.body.scrollWidth; | |
| } |
| /*两个通用函数,用于获取鼠标相对于整个页面的当前位置*/ | |
| function getX(e) { | |
| e = e || window.event; | |
| return e.pageX || e.clientX + document.body.scrollLeft; | |
| } | |
| function getY(e) { | |
| e = e || window.event; |
| /*调节元素透明度的函数*/ | |
| function setOpacity(elem, level) { | |
| //IE处理透明度 | |
| if (elem.filters) { | |
| elem.style.filters = 'alpha(opacity=' + level + ')'; | |
| } else { | |
| elem.style.opacity = level / 100; | |
| } | |
| } |
| /*使用cssdisplay属性来切换元素可见性的一组函数*/ | |
| /** | |
| * 使用display来隐藏元素的函数 | |
| * */ | |
| function hide(elem) { | |
| var curDisplay = getStyle(elem, 'display'); | |
| if (curDisplay != 'none') { | |
| elem.$oldDisplay = curDisplay; |
| /*获取元素当前的高度和宽度*/ | |
| /** | |
| * 获取元素的真实高度 | |
| * */ | |
| function getHeight(elem) { | |
| return parseInt(getStyle(elem, 'height')); | |
| } | |
| /** | |
| * 获取元素的真实宽度 |