dfy
v1.1.8
Published
大房鸭前端解决方案
Downloads
95
Readme
dfy
大房鸭前端工具,为解决开发中出现问题而诞生。
安装插件
全局安装
npm install -g dfy
或者本地安装到项目所在目录。
npm install dfy
##例子
执行dfy -h
命令,查看帮助文档,有init
、server
命令
Usage: dfy [options]
Commands:
init [options] scaffold with specifed template.
server [options] [options] launch a server
Options:
-h, --help output usage information
-V, --version output the version number
###创建项目init [options]
创建一个h5项目目录,只需执行dfy init h5
###启动跨域服务器server [options][options]
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
在本地环境下ajax请求测试服务器数据,后端拒绝的情况下,只需执行dfy server start
默认端口8010,本地请求地址改成http://127.0.0.1:8010/
需要改动端口需要执行dfy server start -p 8020
查看help命令,执行dfy server -h
Usage: server [options] [options]
launch a server
Options:
-h, --help output usage information
-p, --port <int> server listen port
-d, --domain <domain name> domain name
- -p, --port :指定端口,(默认端口8010)
- -d, --domain :指定域名,(默认域名www.dafangya.com.cn/h5/)
AJAX请求,支持GET、POST请求方式
dfy server start -d www.baidu.com
$.ajax({
url: 'http://127.0.0.1:8010/', //指定百度网址
type: 'GET',
data: {
// name:'wiwi'
},
success: function (data) {//请求数据接口进入success回调函数
console.log(data)
},
error: function(data){//请求网页html内容进入error回调函数
console.log(data.responseText)
}
})