Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Maizify committed Apr 27, 2016
0 parents commit 935389e
Show file tree
Hide file tree
Showing 16 changed files with 2,635 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
*.DS_Store
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Livoras

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
89 changes: 89 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
vConsole
==============================
[![npm version](https://badge.fury.io/js/vconsole.svg)](https://badge.fury.io/js/vconsole)

一个针对手机网页的前端 console 调试面板。


## 简介

vConsole 是一个网页前端调试面板,专为手机 web 页面量身设计,帮助开发者更为便捷地进行开发调试工作。

## 手机预览

![](./example/demo.png)

[http://wechatfe.github.io/vconsole/demo.html](http://wechatfe.github.io/vconsole/demo.html)

## 使用方法

### 1.下载模块

checkout 文件 `dist/vconsole.min.js` 到本地。

### 2.引入模块

(1) 如果未使用 AMD/CMD 规范,可直接在 HTML 中引入 vConsole 模块:

`
<script src="path/to/vconsole.min.js"></script>
`

(2) 如果使用了 AMD/CMD 规范,可在 module 内使用 `require()` 引入模块:

`
vConsole = require('path/to/vconsole.min.js');
`

### 3.打印 log 日志

(1) 与 PC 端打印 log 一致,可直接使用 `console.log()` 等方法直接打印日志:

`
console.log('Hello World');
`

未加载 vConsole 模块时,`console.log()` 会直接打印到原生控制台中;加载 vConsole 后,日志会打印到页面前端+原生控制台。

(2) 支持 4 种不同类型的日志,会以不同的颜色输出到前端面板:

`
console.log('foo'); // 白底黑字
console.info('bar'); // 白底紫字
console.debug('oh'); // 白底黄字
console.warn('foo'); // 黄底黄字
console.error('bar'); // 红底红字
`

(3) 支持打印 Object 对象,会以 JSON 字符串格式输出:

`
var obj = {};
obj.foo = 'bar';
console.log(obj); // 打印出 {foo: 'bar'}
`

(4) 支持传入多个参数,会以空格隔开:

`
var uid = 233;
console.log('User ID:', uid); // 打印出 User ID: 233
`

(5) 引入模块后,vConsole 会有一段很小的延迟来用于初始化工作。此时若需打印日志,请使用 `vConsole.ready()` 方法:

`
// vConsole 已自动挂载在全局 window 对象中,即 window.vConsole
vConsole.ready(function() {
console.log('Hello World');
});
`

## 注意事项

引入 vConsole 模块后,页面前端将会在右下角出现 vConsole 的悬停按钮,可展开/收起面板。若不希望普通用户看到面板,请不要在生产环境中引入 vConsole 模块。动态引入模块的方法可参考 `example/demo2.php` 示例。


## License

The MIT License (http://opensource.org/licenses/MIT)
Loading

0 comments on commit 935389e

Please sign in to comment.