npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

h-vue-utils

v1.0.3

Published

Downloads

2

Readme

vue js 工具类

时间类、字符串等工具类集合,会不断更新

Install

npm install h-vue-utils -S

如何使用

//main.js
import Vue from 'vue'
import H from 'h-vue-utils'
Vue.use(H)

工具类介绍

vue统一前缀 this.$H.

字符串 |作用 | 事件名 | 参数 | 类型 | 描述
|------------- | -------------| -------------| -------------| -------------| -------------| ------------- |判断字符串为空 | strUtil.isEmpty | str | string | 返回boolean
|前后空格过滤 | strUtil.trim | str | string | 返回过滤后的值 |判断是否超过限定字数 | strUtil.isOverLimit | strlenNum | stringstring/number | 返回boolean
|截取字符串 | strUtil.subStr | strlenNum | stringstring/number | 结果string |剩余可输入字数 | strUtil.remainChar | strtotal | string =>输入字符串string/number =>总个数 | 结果 11/100 |手机、身份证等号码位数值替换为星号 | strUtil.strTransStar | (str,startIndex,endIndex) | (string,number,number) | 结果 135****2356 |纯数字校验 | strUtil.isNumber | (str) | (string) | 结果 boolean |判断数字,并保留2位小数 | strUtil.isDecimal | (str) | (string) | 结果 boolean |忽略大小写判断字符串是否相同 | strUtil.isCharEqual | (str) | (string) | 结果 boolean |数字转为千分位 | strUtil.parseToQFW | (str,point=2) | (string/number,string/number) | 结果 100,000.02 |中文校验 | strUtil.isChinese | (str) | (string) | 结果 boolean 时间相关 |作用 | 事件名 | 参数 | 类型 | 描述
|------------- | -------------| -------------| -------------| -------------| -------------| ------------- |时间格式化 | dateUtil.format | (date, pattern)| (string/Date,string) | date=> 2018-03-03长短时间、时间戳、new Date()pattern=>yyyy-MM-dd hh:mm:ss 组合式,不填默认yyyy-MM-dd |获取当前时间 某天之前的时间 | dateUtil.getPreDate | (day, curDate, pattern)| (string/number,string,string) | day=> 天数,必填curDate=>格式2018-01-03 传空,默认当天,pattern=>yyyy-MM-dd hh:mm:ss 组合式 |距离当前日期的天数 | dateUtil.getDay | (t) | (string) | t=>时间戳 或时间 |毫秒转时分秒 | dateUtil.formatSeconds | (t, isEn = true) | (string/number,boolean) | t=> 毫秒数isEn 默认01:22:03, false为 1小时22分钟3秒 |判断时间跨度是否超过设定的天数 | dateUtil.isMaxDays | (sTime, eTime, max = 31) | (string,string,string/number) | 结果boolean 开始时间不能大于结束时间 | dateUtil.dateCompare | (sTime, eTime) | (string,string) | 结果boolean url相关 |作用 | 事件名 | 参数 | 类型 | 描述
|------------- | -------------| -------------| -------------| -------------| -------------| ------------- |获取url参数 | urlUtil.getQueryStringByName | (name) | (string) | 1.html?tt=234234 , ('tt') => 234234 url参数转为对象 | urlUtil.urlToObj | (url) | (string) | 结果为一个对象 key:value ** 对象、数组相关** |作用 | 事件名 | 参数 | 类型 | 描述
|------------- | -------------| -------------| -------------| -------------| -------------| ------------- |根据子节点ID 找到所有父节点ID | getTreeAllParent | (treeItems, queryId, queryField = 'id', childKey = 'children', callback, treeTempArray = []) | (array,string/number,string,string,function,array) | this.$H.getTreeAllParent(a,33,'id','children',function(items){console.log(items);}) 【发送消息】参数说明 |参数 | 描述 |------------- | ------------- |moduleName | string类型,对应模块名称,唯一性,on和emit必须对应,必须 |message | object类型,要发送的数据,必须 |ifmId | string类型,当前iframe的ID名称,isParent为true时(即top window发送消息时),必须传 |isParent | boolean类型,true =》top window 发送给 子window ; false =》 子window 发送给 top window(即父级页面),默认false

【接收消息】参数说明 |参数 | 描述 |------------- | ------------- |moduleName | 对应模块名称,唯一性,on和emit必须对应,必须 |callback | 回调函数,参数msg为接收到的数据,function(msg){ console.log(msg); }

  <!-- app.vue -->
  <template>
     <iframe src="http://localhost:8005/iframeTest.html" width="100%" height="600" id="ifr1"></iframe>
     <button @click="doClick">写入iframe</button>
  </template>
  <script>
    export default {
    data() {
        return {
        }
    },
    methods:{
       doClick() {
            //*********发送消息*********
            //top window父级发送消息  emit(发送的消息json,iframeId,true父级发送)
            this.$H.msg.emit({
                moduleName:"checkLogin",
                message:{name:'hello,小子~'},
                ifmId:'ifr1',
                isParent:true
            });
           
            //iframe页面发送消息调用方法
            this.$H.msg.emit({
                moduleName:"checkLogin",
                message:{name:'hello,小子~'}
            });
          

            //*********接收消息*********
            this.$H.msg.on({
              moduleName:"checkLogin", //和emit保持一致
              callback:function(msg){
                console.log(msg);
              }
            });
       }
    }
}
  </script>

options

####### 有问题,请联系

[email protected]

喜欢就加个star吧, thanks very much!