Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
前端框架开发培训
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
cssrain
September 02, 2014
Technology
94
0
Share
前端框架开发培训
前端框架开发培训
cssrain
September 02, 2014
More Decks by cssrain
See All by cssrain
UED工作流程分享和交流
cssrain
1
460
解读HTML
cssrain
0
140
解读HTML5
cssrain
2
160
基础CSS(1)
cssrain
0
150
基础CSS(2)
cssrain
0
100
高效的CSS
cssrain
0
160
高级CSS—继承
cssrain
0
120
PhoneGap分享和交流
cssrain
0
93
PhoneGap实践
cssrain
0
77
Other Decks in Technology
See All in Technology
音声言語モデル手法に関する発表の紹介
kzinmr
0
150
PicoRuby as a Multi-VM Operating System
kishima
1
220
AI時代 に増える データ活用先
takahal
0
330
Choose your own adventure in agentic design patterns
glaforge
0
160
弁護士ドットコム株式会社 エンジニア職向け 会社紹介資料
bengo4com
1
190
Route 53 Global Resolver で高額課金発生!
otanikohei2023
0
130
20年前の「OSS革命」に学ぶ AI時代の生存戦略
samakada
0
500
20260423_執筆の工夫と裏側 技術書の企画から刊行まで / From the planning to the publication of technical book
nash_efp
3
610
データ定義の混乱と戦う 〜 管理会計と財務会計 〜
wonohe
0
150
Oracle AI Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
4
2.4k
社内エンジニア勉強会の醍醐味と苦しみ/tamadev
nishiuma
0
250
Shipping AI Agents — Lessons from Production
vvatanabe
0
290
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
How GitHub (no longer) Works
holman
316
150k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
440
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
170
Design in an AI World
tapps
1
200
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
180
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
110
4 Signs Your Business is Dying
shpigford
187
22k
Building Applications with DynamoDB
mza
96
7k
Chasing Engaging Ingredients in Design
codingconduct
0
180
Utilizing Notion as your number one productivity tool
mfonobong
4
290
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2k
Transcript
单东林 2013年04月 前端框架开发培训 UED分享 · 交流 http://cssrain.github.io
1,开发模式 2,数据整合 3,开发规范 浏览器兼容性管理 文件目录管理 Lib源管理 内容:
1,开发模式
Ajax开发模式 所有页面的数据都是从前台发送ajax请求,后台返回的形式。所有操作都 是异步模式。
$.PostJson(url , params ,callback) 为了让代码更加统一,规范,我们把Ajax封装了。它有3个参数,第1个为 请求的url,第2个为传递的参数,第3个回调函数。
$.PostJson(url , params ,callback) 为了让代码更加统一,规范和方便维护,我们所有Ajax要发送请求的URL集 合到一个js中,通过全局方式来调用。同时,我们会把JSON分为2个版本, 本地一份,远程一份。
Ajax封装: $.extend({ PostJson: function(url, datas , callback) { $.ajax({ url:
url, type: "GET", data : datas +"&_=" + (new Date()).getTime(), cache: false, dataType: “json", success: function(json) { callback("success", json); }, error: function(e) { callback("error", null); } });
配置URL本地数据和远程数据: var conf = 1 ; //数据配置数组的配置参数,0为本地数据,1为远程数据 var srcPref =
["res/data/","front/sh/"]; var dataArray = [ { //本地数据 "index": srcPref[conf]+"advertisements.json", "brandModel" : srcPref[conf]+"top.json“ }, { //远程数据 "index": srcPref[conf]+"business!getHomeJson?uid=home", "brandModel" : srcPref[conf] + "business!getBrandModel" } ]; window.dataArray = dataArray[conf];
Ajax加载数据的典型代码: $.PostJson( dataArray.index , "opId="+opId+"&op="+op,function(state,json){ //判断Ajax请求是否成功 if(state=="success"){ //判断返回数据是否成功 if(json.returnCode==“0”){ //成功
}else{ //失败 } }else{ //失败 } });
2,数据整合
JS模板 + JSON = HTML 传统模式:后台输出json,前台把json解析,拼接成HTML插入到页面中
Handlebars.js 它是JavaScript一个语义模板库,通过对view和data的分离来快速构建 Web模板。它采用“Logic-less template”(无逻辑模版)的思路。
JS模板 + JSON = HTML
<div class="entry"> <h1> {{title}} </h1> <div class="body"> {{body}} </div> </div>
{{ }} ???
如何使用它? 官方网站:http://handlebarsjs.com/ 教程: http://software.intel.com/zh-cn/articles/html5handlebars
3,开发规范
浏览器兼容性管理 保证代码样式,脚本在规定的浏览器下正常运行。
文件目录管理 文 件 目 录 样 式 目 录 样式CSS和image必须处于同一
目录,Images文件夹里的图片 需要分模块放。 脚 本 目 录 项目中所有使用的类库,目录命名必须是: 脚本名 / 版本号 / 脚本名.js。 如引入1.7.2版的jQuery: res/lib/jquery/1.7.2/jquery.js 类库分为压缩版和未压缩版,压缩版请以 “类库名.min.js” 命名。
Lib源地址 所有的脚本库都需要从Lib源中获取,Lib源已放置在项目中。如果没有相 关的lib,可讨论后再添加Lib源。切勿随意添加lib,随意引入其他脚本效 果!
目前已有的源: 表格,表单提交,弹出层,树等Lib都有。
Q&A
感 谢 聆 听