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

熱點內容
maya粒子表達式教程 瀏覽:84
抖音小視頻如何掛app 瀏覽:283
cad怎麼設置替補文件 瀏覽:790
win10啟動文件是空的 瀏覽:397
jk網站有哪些 瀏覽:134
學編程和3d哪個更好 瀏覽:932
win10移動硬碟文件無法打開 瀏覽:385
文件名是亂碼還刪不掉 瀏覽:643
蘋果鍵盤怎麼打開任務管理器 瀏覽:437
手機桌面文件名字大全 瀏覽:334
tplink默認無線密碼是多少 瀏覽:33
ipaddgm文件 瀏覽:99
lua語言編程用哪個平台 瀏覽:272
政采雲如何導出pdf投標文件 瀏覽:529
php獲取postjson數據 瀏覽:551
javatimetask 瀏覽:16
編程的話要什麼證件 瀏覽:94
錢脈通微信多開 瀏覽:878
中學生學編程哪個培訓機構好 瀏覽:852
榮耀路由TV設置文件共享錯誤 瀏覽:525

友情鏈接