1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        Drv.js前端 MVVM 開發(fā)框架

        聯(lián)合創(chuàng)作 · 2023-09-19 11:40

        Drv.js

        組合式前端 MVVM / MVC / SPA 開發(fā)框架,基于 Director.js + Require.js + Vue.js 等組件構(gòu)建。

        安裝

        bower install drv.js --save

        框架與依賴

        bower.json 的其他依賴項 vue-touch, vue-validator, jquery, requirejs-text, underscore, require-css, tiletemplate 默認(rèn)不加載,用戶需要使用時自行引入依賴才加載 . 如果你不需要這些組件,你可以編輯 bower.json 后更新或者執(zhí)行卸載命令 bower uninstall vue-touch vue-validator jquery requirejs-text underscore require-css tiletemplate.

        兼容性

        • Firefox 4.0+

        • Chrome 7+

        • IE 9+

        • Opera 11.60+

        • Safari 5.1.4+

        Drv.js 基于 ES5 (ECMAScript 5) 開發(fā)。 ECMAScript 5 兼容性數(shù)據(jù)表 : http://kangax.github.io/compat-table/es5/.

        應(yīng)用目錄結(jié)構(gòu)

        you-app/
            bower_components/
            controllers/
            configs/
            images/
            views/
            css/
            lib/ 
            ... 
            bower.json
            index.html
            main.js

        使用方法

        index.html :

        <script src="./bower_components/requirejs/require.js"></script>
        <script drv-main="./main" src="./bower_components/drv.js/dist/drv.min.js"></script>

        入口文件 main.js :

        define(["./configs/routes"], function(routes) {
            var app = Drv.App(); // or Drv.App({your-configs ...});
            app.run(routes);
        });

        配置項參考 console.log(Drv.defaults); 或者 console.log(app.settings);

        路由配置文件 routes.js :

        define({
            "/" : function() {},     // Director.js 原有的方式
            "/books" : "book/index", // 使用控制器自動加載 you-app/controllers/book/index.js
            "/books/:id" : "book/view",
            "/author" : "author",
            "/about" : "about"
        });

        路由 (Director.js) API 文檔 https://github.com/flatiron/director#api-documentation

        控制器文件 book/view.js:

        // 你可以使用 Require.js css / text 插件來加載
        define(["your-deps"], function() {
            var app    = Drv.getApp();   // 獲取 App 單例對象    
            var router = app.router;     // router.getRoute(), router.getPath()     
            var params = router.$params; // Vue ViewModel 選項參數(shù)
        
            var vmOptions = {
                el   : "#layout",
                data : {
                    id : params[0],
                    name : "Drv.js" },
                ready : function() {
                    console.log("Vue.$http", this.$http);
                },
                methods : {
                    clickDiv : function(e) {
                        console.log(e.target);
                    }
                }
            };     
            // 渲染視圖文件 you-app/views/index.html     
            app.render("index", vmOptions);
        });

        視圖模型(Vue.js) 使用指南:http://cn.vuejs.org/guide/

        視圖文件 views/index.html:

        <h1>View index.html {{name}} id={{id}}</h1>
        <input v-model="name" />
        <div style="width:100px;height:100px;background:green;color:#fff;" v-on="click:clickDiv">Drv.js</div>

        視圖模型指令參考資料: http://vuejs.org/api/directives.html

        參考文檔

        瀏覽 24
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        編輯 分享
        舉報
        評論
        圖片
        表情
        推薦
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        編輯 分享
        舉報
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            中国老熟女重囗味HDXX | 色噜噜成人 | 国产探花第一页 | 无码欧美日韩二区三区蜜桃 | 老女人综合网 | 国产综合成人A片精品导航 | 贵妇灬好爽小坏蛋 | 无码少妇一区二区三区 | 少妇精品免费视频欧美 | 啊啊啊不要高潮了 |