構建基於Javascript的移動web CMS——Hello,World

來源:互聯網
上載者:User

標籤:orm   require   mustache   head   use   rip   build   sni   div   

在一篇構建基於Javascript的移動web CMS入門——簡單介紹中簡單的介紹了關於墨頎CMS的一些原理,其極架構組成。於是開始接著應該說明一下這個CMS是怎樣一步步搭建起來。

RequireJS 使用庫及依賴

這裡用的是bower的JS來下載庫。具體能夠參考一下bower install js使用bower管理js 這篇文章。

須要下載的庫有

  • RequireJS
  • Backbone
  • Underscore
  • Mustache
  • jQuery
使用RequireJS

引用官網的示範範例

<!DOCTYPE html><html>    <head>        <title>My Sample Project</title>        <!-- data-main attribute tells require.js to load             scripts/main.js after require.js loads. -->        <script data-main="js/main" src="lib/require.js"></script>    </head>    <body>        <h1>My Sample Project</h1>    </body></html>

我們須要一個require.js和一個main.js放在同一個檔案夾,在main.js中用使用require()來載入須要載入的指令碼。

require.config({    baseUrl: ‘lib/‘,    paths: {        jquery: ‘jquery-2.1.1.min‘    },    shim: {        underscore: {            exports: ‘_‘        }    }});require([‘../app‘], function(App){    App.initialize();});

在config中能夠配置好其它的庫,接著調用了app.js。

define([‘jquery‘, ‘underscore‘], function($, _){    var initialize = function() {        console.log("Hello World");    }    return {        initialize: initialize    };});

當開啟index.html的時候便會在console中輸出Hello World

這樣我們就完畢一個主要的架構,僅僅是還沒有HTML,這個將會在下次繼續。

相關資源

QQ討論群: 344271543

原始碼 Github: https://github.com/gmszone/moqi.mobi

構建基於Javascript的移動web CMS——Hello,World

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.