Framework7——基础工具类

        /**
         * Framework7
         **/
        function SeabootFramework7(option) {
            var root = $(document);
            if (typeof option !== 'undefined') {
                initDom(option);
                root = option.dom;
            }

            /**
             * 查找dom对象
             * */
            function initDom(option) {
                if (typeof option.elem === 'string') {
                    option.dom = root.find(option.elem);
                } else if (typeof option.elem === 'object') {
                    option.dom = option.elem;
                } else {
                    throw 'elem is undefined!';
                }
            }

            /**
             * 绑定值
             */
            function bindValue(dom, data) {
                dom.find('*').each(function () {
                    var d = $(this), id = d.attr('id');
                    if (typeof id !== 'undefined') {
                        var v = data[id];
                        if (typeof v !== 'undefined') {
                            d.text(v);
                        }
                    }
                })
            }

            /**
             * 内置模版渲染
             **/
            function compile(str, data) {
                return Template7.compile(str)(data);
            }

            /**
             * 函数
             **/
            return {
                bindValue: bindValue,
                compile: compile
            }
        }
原文地址:https://www.cnblogs.com/chenss15060100790/p/11199353.html