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

熱點內容
金蝶kis支持win10嗎 瀏覽:113
常州採集物聯網大數據平台有哪些 瀏覽:950
win10休眠文件改到d盤 瀏覽:626
如何編程手機app軟體 瀏覽:656
node獲取文件名 瀏覽:367
iphoneios7怎麼設置鈴聲 瀏覽:52
手機qq激活星鑽 瀏覽:302
html中引入js文件路徑 瀏覽:83
0基礎自學編程可以看什麼書 瀏覽:860
javapoi導出excel 瀏覽:212
迷你編程迷小酷為什麼郵箱里沒有 瀏覽:33
ipadqq接收的文件在哪裡 瀏覽:15
拼多多初級看哪些數據 瀏覽:848
win10開機密碼屏幕鍵盤 瀏覽:162
文件夾樂高 瀏覽:914
外置文件夾掛載 瀏覽:304
人人視頻本地緩存文件 瀏覽:194
java俄羅斯方塊項目描述 瀏覽:354
win10系統被凍結 瀏覽:460
excel文件批量合並 瀏覽:948

友情鏈接