Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
SeaJS TUI实践
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
luolonghao
May 22, 2013
Technology
100
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SeaJS TUI实践
luolonghao
May 22, 2013
More Decks by luolonghao
See All by luolonghao
About HRT and TPM
luolonghao
0
80
KindEditor 设计思路 V2
luolonghao
1
180
Other Decks in Technology
See All in Technology
AIがコードを書く時代に、エンジニアは何で自分の価値を証明するのか / In an era where AI writes code how do engineers prove their value
carta_engineering
3
1.1k
脆弱性診断って、何をしているの? 〜弱点を見つけて、会社の改善につなげるまで〜
keeg
0
920
夫婦で子育てするための育児標準化
codmoninc
PRO
0
330
QA4AI 2026-Oct 生成AI時代の品質保証
tokuty
1
860
今さら理解するウェブフォントver.2026
takanorip
3
770
Persisting Massive Data with Rails ~Designing for 60 billion rows, and fighting the bottlenecks~ Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
730
継続的なAIコスト最適化
bgpat
1
340
AI駆動で「他アプリの音を加工できる」アプリを作った
satomasahiro2005
0
150
Getting Started with Google Antigravity
glaforge
0
300
実践!Cloud Run ハンズオン!! / Cloud Run handson
y0hgi
2
280
Rust で関数型ドメインモデリング
takonda
0
140
Conditional PED-ANOVA: Hyperparameter Importance in Hierarchical & Dynamic Search Spaces
pfn
PRO
0
130
Featured
See All Featured
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.2k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
A Modern Web Designer's Workflow
chriscoyier
699
190k
BBQ
matthewcrist
90
10k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.7k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
800
Darren the Foodie - Storyboard
khoart
PRO
4
4k
Utilizing Notion as your number one productivity tool
mfonobong
4
620
Transcript
SeaJS + TUI实践 2012.10.08
SeaJS、CMD SeaJS:模块加载器 CMD:SeaJS的模块定义规范
入门代码(HTML) <!doctype html> <html> <head> <title>Hello</title> </head> <body> <script src=“http://js.tudouui.com/js/v3/seajs/sea.js"></script>
<script> seajs.config({ alias: { 'jquery‘ : ‘jquery/1.7.2/jquery.js‘, ‘hello’ : ’hello/dist/hello.js’ }, base : ‘http://js.tudouui.com/js/v3/’ }); seajs.use('/page/demo/dist/main.js'); </script> </body> </html>
入门代码(main.js) define(function(require, exports, module) { var Hello = require(‘hello'); new
Hello(); });
入门代码(hello.js) define(function(require, exports, module) { var $ = require('jquery'); function
Hello(){ this.render(); }; Hello.prototype.render = function(){ $('<h1>Hello SeaJS !</h1>').appendTo('body'); }; return Hello; });
目录结构 static/v3/ jquery/ 1.8.1/ json/ 1.0.2/ tui/ dist/ src/ tuilib/
dist/ src/ hello/ dist/ src/ page/ demo/ dist/ src/
改造老代码 • 用define(function(require) {…});包起来 • @import ./xxx.js改成require(‘./xxx’); • 用window暴露全局变量,或用exports返回 •
TUI.module.use(‘/fn/tuidefer’, fn)改成require.async(‘tuidefer’, fn) • TUI.convertTpl(‘./xxx.tpl‘, data)改成TUI.convertTpl(require(‘./xxx.tpl’), data)
这样做有什么好处? • 可在浏览器端加载依赖,这样页面可以直 接调用源代码,无需打包,对单元测试友 好 • 控制入口,可重写任何URL(比如,加时间 戳,用debug插件调试) • 与Node模块非常相近,很容易迁移
单元测试(V2) // stat.js,通过打包工具合并后才能调用 /** * @import fn/MRG32k3a.js * @import fn/global/common_stat.js
* @import fn/global/pv_stat.js * @import fn/global/expose_stat.js */ var ComboPvStat = { // some code }; ComboPvStat.send();
单元测试(V3) // stat.js,可以直接调用,无需打包 define(function(require, exports, module) { require('./MRG32k3a'); require('./common_stat'); require('./pv_stat');
require('./expose_stat'); var ComboPvStat = { // some code }; ComboPvStat.send(); });
调试(V2) 依赖本地代理(makeasy)
调试(V3) 本地运行HTTP服务,URL后加seajs-debug参数 // debug.js rules.push([ 'http://js.tudouui.com/js/v3/page/demo/dist', 'http://localhost/js/v3/page/demo/src' ]);
打包、压缩(V2)
打包、压缩(V3) // 安装SPM $ git clone https://github.com/seajs/spm.git $ cd spm
$ npm install –g // 打包、压缩 $ cd v3/hello $ spm build
参考文档 V3代码: trunk/static/js/v3 SeaJS:http://seajs.org/docs/#api CMD:https://github.com/seajs/seajs/issues/242 SPM:https://github.com/seajs/spm/wiki