導航:首頁 > 編程語言 > 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 瀏覽:172
cad文件為什麼顯示文件名是否正確 瀏覽:174
程序配置文件能自動轉換成txt 瀏覽:985
r4燒錄卡不同版本 瀏覽:962
怎麼升級qq群為2000 瀏覽:347
微信己冊除的文件怎樣找回來 瀏覽:715
蘋果美國賬號共享2017 瀏覽:252
ps文件修改後打開還是原圖 瀏覽:220
燒卡機蘋果4微信qq哪裡下載 瀏覽:780
ug120找不到指定文件 瀏覽:522
cda文件怎麼轉換成mp3格式 瀏覽:702
青島hpv疫苗在哪個app預約 瀏覽:881
雙十一成交額2021數據在哪裡看 瀏覽:631
蘋果手機怎麼打開移動數據 瀏覽:637
文件掃描成圖片是彩色的嗎 瀏覽:50
編程里的comply什麼意思 瀏覽:91
電腦上面點了禁用網路怎麼改回來 瀏覽:28
javacatch執行 瀏覽:182
ps軟體文件名字 瀏覽:184
黑蘋果查找文件路徑 瀏覽:397

友情鏈接