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

熱點內容
長江大學網課用什麼app 瀏覽:431
華中系統圖紙編程哪個刀好 瀏覽:38
地方債務數據在哪裡查看 瀏覽:932
掃描文件怎麼設置格式 瀏覽:957
蘋果郵箱主機名填什麼 瀏覽:630
多張圖片同一個文件夾 瀏覽:798
win7怎麼打開shs文件 瀏覽:481
怎麼把文件夾做成iso 瀏覽:164
繽客網站上的房價怎麼在哪裡修改 瀏覽:406
單片機c51計數器實驗代碼 瀏覽:990
宏編程滑鼠代表什麼意思 瀏覽:753
別人撿到蘋果6有用嗎 瀏覽:829
word文件用wps打開 瀏覽:477
macbook修改文件格式軟體 瀏覽:757
美版s7edge那個版本好 瀏覽:529
視頻隱藏在文件夾里 瀏覽:144
網路通訊基礎是什麼 瀏覽:209
辦公電腦文件管理 瀏覽:222
火化費報銷文件有哪些 瀏覽:998
大數據這本書怎麼樣 瀏覽:954

友情鏈接