導航:首頁 > 編程語言 > 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相關的資料

熱點內容
虎口脫險中譯版本由 瀏覽:160
花兒教育app怎麼老是更新啊 瀏覽:557
用戶配置文件目錄 瀏覽:974
重啟網路適配器 瀏覽:414
市面上一般pd數據線多少錢 瀏覽:565
更新app怎麼換賬號 瀏覽:905
一個視頻網站能賺多少錢 瀏覽:357
在電腦上怎麼復制文件 瀏覽:496
我的世界文件夾mod在哪裡 瀏覽:525
蘋果5s測評 瀏覽:782
安全文件夾在哪裡下 瀏覽:643
catpart文件名怎麼設置 瀏覽:39
PDF檔文件怎麼另存為 瀏覽:402
網路機頂盒恢復出廠怎麼能下載 瀏覽:4
網頁元素代碼 瀏覽:67
讀書選擇版本的原因 瀏覽:992
如何用數據線傳文件 瀏覽:335
java使用jni 瀏覽:432
p970升級錯誤修復 瀏覽:119
米4文件管理在哪 瀏覽:376

友情鏈接