Giter Site home page Giter Site logo

deerberry's Introduction

deerberry.js

Usage

Ajax

XMLHttpRequest

Examples
db.Ajax({

    //必填项
    url: "url",

    /**
     * 可选项
     * default value : "GET"
     * method
     */
    type: 'POST',

    /**
     * 可选项
     * default value : {}
     * post data
     */
    data: {
        key1: 'value1',
        key2: 'value2'
    },

    /**
     * 可选项
     * default value : 'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8'
     */
    headers:{
        'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
        'Accept': 'application/json'
    }

    /**
     * 可选项
     * default value : null
     * jsonp回调函数,回调函数名为"jsonpCallbak"
     * 可以设置为合法的字符串。添加此option会使用jsonp请求跨域数据
     */
    jsonp: 'jsonpCallbackFunctionName',

    success: function (res) {},
    error: function (error) {}
});

requireJs

动态加载JS文件

/**
 * @param {String} url 文件路径
 * @param {Function} callback
 */
db.requireJs(url, function(){})

getLocalIpInfo

获取本地IP信息

/**
 * @param {String} ip
 * @param {Function} callback
 */
db.getLocalIpInfo(ip, function(res){
    console.log(res)
})

pullRefresh

下拉刷新

Examples
/* pull refresh module */
.pullRefresh__scroller .pullRefresh__loading {
  height: 80px;
  line-height: 80px;
  text-align: center;
  width: 100%;
  background-color: #fff;
  color: blue;
}

.pullRefresh__scroller {
  -webkit-overflow-scrolling: touch;
}
<div id="scroll_container" class="pullRefresh__scroller">
    <!-- loading dom -->
    <div class="pullRefresh__loading"></div>

    <!-- list dom-->
    <ul></ul>
</div>
/**
 * @param {Object}
*/
db.pullRefresh({
    container: "#scroll_container", //外层的容器
    next: function (e) {
        var that = this;

        // callback function could be code there

        that.back.call();
    }
});

scrolltobottom

上拉加载更多

/**
 * @param {Function} callback
*/
db.scrolltobottom(callback)

historyLength

历史列表元素数量

/**
 * @return {Int}
*/
db.historyLength()

redirectHtml

重定向页面,不添加新的浏览器历史记录

/**
 * @param {String} url
*/
db.redirectHtml(url)

⬆ Back to top

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.