# jjychengtoolsbox **Repository Path**: jjycheng/jjychengtoolsbox ## Basic Information - **Project Name**: jjychengtoolsbox - **Description**: js常用工具jjychengtoolsbox;获取URL参数,获取Cookie,设置Cookie, 时间万能转换-兼容IE,截取字符串,过滤全部html,生成随机数,检查是否手机端访问 - **Primary Language**: JavaScript - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-03-11 - **Last Updated**: 2024-03-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # jjychengtoolsbox ## 介绍 "获取URL参数", "获取Cookie", "设置Cookie", "时间万能转换-兼容IE", "截取字符串", "过滤全部html", "生成随机数", "检查是否手机端访问" ## 作者 "author": "JJY.Cheng", "blogUrl":https://cplvfx.blog.csdn.net/" "NPM项目地址":https://www.npmjs.com/package/jjychengtoolsbox?activeTab=readme ## 使用演示 ### 安装 ``` bash npm i jjychengtoolsbox ``` ### 引入 ``` js import jjychengtoolsbox from 'jjychengtoolsbox'; ``` ### 使用 #### 根据名称获取URL参数 ``` js jjychengtoolsbox.GetQueryStringFun('参数名称') ``` #### 获取Cookie ``` js jjychengtoolsbox.getCookieFun('名称') ``` #### 设置Cookie ``` js jjychengtoolsbox.setCookieFun('名称') ``` #### 时间万能转换-兼容IE ``` js jjychengtoolsbox.DateTimeConvertFun('时间字符串','格式') // 格式如下: // 'yyyy/mm/dd hh:mm' // 'yyyy/mm/dd' // 'yyyy-mm-dd hh:mm' // 'yyyy-mm-dd' // 'yyyy年mm月dd日' ``` #### 截取字符串 ``` js jjychengtoolsbox.SliceTxtFun('字符串','截取长度(数字)') ``` #### 过滤全部html标签 ``` js jjychengtoolsbox.FilterHtmlFun('字符串') ``` #### 生成随机数 ``` js jjychengtoolsbox.RandomNumberFun('起始数字','结束数字') ``` #### 检查是否手机端访问 ``` js jjychengtoolsbox.IsMobileFun() //如果是手机访问,返回true,否则false ``` ### 完整演示 #### js ``` js import jjychengtoolsbox from 'jjychengtoolsbox'; export default { name: 'App', components: { HelloWorld }, data(){ return { jjyT:{}, FilterHtml:'', } }, created(){ this.jjyT=jjychengtoolsbox; console.log(this.txt) console.log(jjychengtoolsbox) this.jjyT.setCookieFun('jjyT','jjychengtoolsbox',1);//设置Cookie this.FilterHtml=this.jjyT.FilterHtmlFun('1.我是粗体;2.我是斜体;3.我是超链接;');//过滤html } } ``` #### html ```html
名称 | 描述 | 例子 |
GetQueryStringFun 根据名称获取URL参数 |
如url:http://localhost:8081/?id=1 我想拿到id的值 |
id={{jjyT.GetQueryStringFun('id')}} |
getCookieFun 获取Cookie |
如: jjyT.setCookieFun('jjyT','jjychengtoolsbox',1) |
{{jjyT.getCookieFun('jjyT')}} |
DateTimeConvertFun 时间万能转换-兼容IE |
如: 时间戳:1709977671 时间字符串:2024-3-9 17:47:51 |
时间戳:{{jjyT.DateTimeConvertFun('1709977793','yyyy年mm月dd日')}} 时间字符串:{{jjyT.DateTimeConvertFun('2024-3-9 17:47:51','yyyy年mm月dd日')}} |
SliceTxtFun 截取字符串 |
如: 截取字符串123456 |
{{jjyT.SliceTxtFun('截取字符串123456',5)}} |
FilterHtmlFun 过滤全部html |
如: 1.我是粗体;2.我是斜体;3.我是超链接; |
{{FilterHtml}} |
RandomNumberFun 生成随机数 |
如:1-5 | {{jjyT.RandomNumberFun(1,5)}} |
IsMobileFun 检查是否手机端访问 |
如:1-5 | {{jjyT.IsMobileFun()}} |