导航:首页 > 编程语言 > respondjs

respondjs

发布时间:2025-01-18 23:04:17

⑴ sails 多维json怎么遍历

一、安装时:

先装nodejs,成功标志 node -v

安装sails 全局安装 node install sails@version -g 安装成功 sails -v

创建 项目 sails new projectname

安装grunt : npm install grunt@version --save-dev(在项目的目录中)

启动sails服务:sails lift

在启动时提示的错误,可以用 npm install 在当前的项目下进行安装。

在创建api时用命令:sails generate api book(在安装后很可能sails lift时会出现错误,此次的处理是npm install sails-config --save-dev

测试浏览:http://localhost:1337/user 创建http://localhost:1337/user/create?name=xy&password=fc12345

note:to avoid the migration warning from sails when generating the book api,add the following to config/env/development.js

models:{

migrate:"alter"

}

二、文件夹:

assets下可以放直接被url调用的网页,图片,js,等文件,url http://localhost:1337/在assets下的路径。

三、路由

config/routes.js

'/':{view:'homepage'} localhost:1337

'/about':{view:'about'} localhost:1337/about 在views下创建 about.ejs

路由蓝图包括以下三种:

restful路由

These routes always have the path of /:modelName or /:modelName/:id

and send the request to the appropriate action by using the HTTP "verb".Middleware policies should be used in a proction environment to protect these routes fromuauthorized access.

shortcut路由

these routes only respod to "get" requests and determine which action to send the request to by decoding the path.An example path would look like

/:modelName/<action> and data would be passed to the controller action using query parameters. While great for development work o a prototype,these routes should be disabled in proction.

action路由

Thes routes create shortcut routes for custom actions tat don't come for free as part of the restful routes.So for any custom action on a controller,a corresponding path followingthe format /:controllerName/:actionName whill respond to get requests and send the request to the controller.

Blueprit Actions

The Blueprint API creates a number of generic actions tohandleall of the standard behaviour of a restful JSON API to match the BluePrint routes.The following default controller actions,which can be overridden,are provided by the Blueprint api:

find findOne create update destory populate add remove

如何使用 http verb?

'get /posts':{

controller:'postsController',

actio:'list'

}

这个配置告诉应用对get 的请求做出回应,在url处理方式为postscontroller下的list操作。

‘put /posts/:id':{

controller: 'postsController',

action:'update'

}

这个配置对put请求做出回应,更新一个已存在的用户,其中id为参数,update是postsController中的一个操作。

如何更改模板?

1.用jade 代替 Ejs

npm install jade --save

更改config/views.js文件:

mole.exports.views={

engine:'jade',

layout:fasle,这个只有ejs支持,所以换成jade后,要把layout设为false;

locals:{//any options you would like to pass to the jade parser}

}

最后从package.json中移走ejs;

样式文件的替换用sass 替换 less

1.把grunt-contrib-less从age.json中移走,npm install grunt-contrib-sass --save

2.改变所有Grunt task 中的less 引用为 sass.(需要改变的有如下文件)

tasks/cofig/.js

tasks/register/compileAssets.js

tasks/register/syncAssets.js

其实如果是新项目了只需更改 tasks/importer.less为importer.sass,其它的都由Sass自动适配。

用postgres 代替LocalDB

waterline (与许多流行的数据库一起工作)(如:Postgresql,MongoDB,Redis.)

⑵ 浏览器不支持CSS3Media Query怎么办

IE6~8不支持CSS3 Media Query,需要借助respond.js插件。

respond.js插件下载地址:https://www.developgeek.com/plus/list.php?tid=62

demo.css 样式文件

html,body{
height:100%;
}
@mediaonlyscreenand(min-width:480px){
body{
background:yellow;
}
}
@mediaonlyscreenand(min-width:640px)and(max-width:1024px){
body{
background:green;
}
}
@mediascreenand(min-width:1024px){
body{
background:blue;
}
}

respond.js demo实例

<!doctypehtml>
<html>
<head>
<metacharset="UTF-8">
<title>HTML5-响应式布局--respond.js-言成科技&HTML5学堂</title>
<linkrel="stylesheet"type="text/css"href="demo.css"/>
<scriptsrc="respond.min.js"></script>
</head>
<body>
<divclass="wrap"id="con">
让IE6~8支持响应式布局——言成科技&HTML5学堂
</div>
</body>
</html>

注意:respond.min.js或者respond.src.js都可以使用,在上面给出的下载地址中下载即可。

IE6的显示效果

Tips:IE7-8的显示效果也是没有问题的,在此就不贴图处理了

阅读全文

与respondjs相关的资料

热点内容
2008打开登录密码忘记了 浏览:771
苹果7如何授权应用程序 浏览:899
怎样把旧的文档保存到桌面文件夹 浏览:827
wps云数据如何恢复 浏览:496
微信发送过来文件 浏览:300
怎么改合同网站 浏览:73
网络斗地主记牌器怎么实现的 浏览:377
ps镜像文件制作教程 浏览:45
系统分页文件大小设置多少 浏览:447
win10有线无法上网 浏览:339
wps无法访问指定文件 浏览:96
iphone4震动坏了 浏览:217
安卓随机数软件rand 浏览:356
CNC编程如何掌握公差 浏览:297
linux搭建php环境 浏览:514
星形网络怎么表示有故障 浏览:719
dbf文件c语言处理excel 浏览:138
金蝶kis支持win10吗 浏览:113
常州采集物联网大数据平台有哪些 浏览:950
win10休眠文件改到d盘 浏览:626

友情链接