global-source/javascript_uri_query

URI CURD 核心JavaScript库。

1.0 2017-01-28 05:34 UTC

This package is not auto-updated.

Last update: 2024-09-15 01:52:43 UTC


README

强大的URL级别操作(添加、更新、删除等)的核心JavaScript库...

Packagist Packagist

一个库可以执行大多数 URI 操作。例如,

安装

通过以下方式将URI库包含到项目中:

    <script src="uri_helper.min.js"></script>

对于 ES6

    <script src="uri_helper_es6.min.js"></script>
    <script>
     let URI = new _URI(); 
    </script>

方法

getAll()

获取URI参数列表作为对象。

    
           URI.getAll();    
        
        // URL : http://domain.com/?type=my-ticket&page=1&limit=5
        
        // Output : ["type=myTicket", "page=1", "limit=5"]
        

get()

从URI获取参数值。

           URI.get('type');
        
        // URI : http://domain.com/?type=myTicket&page=2&limit=5
        
        // OUT : 'myTicket'

addNew()

向URI添加单个参数。如果项目已存在,则更新值。

   
           URI.add('page', 1);
        
        // Before URL : http://domain.com/?type=my-ticket
        
        // After URL : http://domain.com/?type=my-ticket&page=1
        

add()

向URI添加参数列表。如果项目已存在,则更新值。

   
           URI.add([{'page': 1}, {'limit': 5}]);
        
        // Before URL : http://domain.com/?type=my-ticket
        
        // After URL : http://domain.com/?type=my-ticket&page=1&limit=5
        

append()

向URI中的参数追加值。

   
           URI.append(name, bala);
        
        // Before URL : http://domain.com/?name=shankar
        
        // After URL : http://domain.com/?name=shankar,bala
        

remove()

从URI中删除参数列表。

  
           URI.remove(['page','limit']);   // For Bulk.
           URI.remove('type');             // For Single.   
           URI.remove('id','55')       // For Single Value.
        
        // Before URL : http://domain.com/?type=my-ticket&page=1&limit=5
        
        // After URL : http://domain.com/?
        
        // For Single Value:
        // Before URL : http://domain.com/?id=45,23,55,34
        
        // After URL : http://domain.com/?id=45,23,34

removeAll()

从URI中删除所有参数。

   
           URI.removeAll();
        
        // Before URI : http://domain.com/?type=my-ticket&page=2&limit=5
        
        // After URI : http://domain.com/?

prevPage()

通过更新URI返回上一页。

   
           URI.prevPage();
        
        // Before URL : http://domain.com/?type=my-ticket&page=2&limit=5
        
        // After URL : http://domain.com/?type=my-ticket&page=1&limit=5

nextPage()

通过更新URI跳转到下一页。

   
           URI.nextPage();
        
        // Before URL : http://domain.com/?type=my-ticket&page=1&limit=5
        
        // After URL : http://domain.com/?type=my-ticket&page=2&limit=5
        

isParamExists()

检查参数是否存在于URI中。

        
           URI.isParamExists('page');        
           URI.isParamExists('newPage');
        
        // URL : http://domain.com/?type=my-ticket&page=2&limit=5
        
        // OUT 1 : true
        // OUT 2 : false
       

许可证

MIT许可证