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 🙏

© 2025 – Pkg Stats / Ryan Hefner

usecorehocks

v0.0.2-beta.1

Published

一个自定义 Vue 3 组件和指令库,包含自定义按钮组件和 resize 指令。

Readme

Custom-Hocks

一个自定义 Vue 3 组件和指令库,包含自定义按钮组件和 resize 指令。

安装

npm install usecorehocks
# 或
yarn add usecorehocks
# 或
pnpm add usecorehocks

使用方法

全局注册

import { createApp } from "vue";
import App from "./App.vue";
import CustomHocks from "usecorehocks";

const app = createApp(App);
app.use(CustomHocks);
app.mount("#app");

自定义按钮组件

<template>
  <div>
    <!-- 基本用法 -->
    <CustomButton>默认按钮</CustomButton>
    <CustomButton type="primary">主要按钮</CustomButton>
    <CustomButton type="success">成功按钮</CustomButton>
    <CustomButton type="warning">警告按钮</CustomButton>
    <CustomButton type="danger">危险按钮</CustomButton>
    <CustomButton type="info">信息按钮</CustomButton>

    <!-- 朴素按钮 -->
    <CustomButton plain>朴素按钮</CustomButton>

    <!-- 圆角按钮 -->
    <CustomButton round>圆角按钮</CustomButton>

    <!-- 圆形按钮 -->
    <CustomButton circle>
      <template #icon>
        <span>+</span>
      </template>
    </CustomButton>

    <!-- 禁用状态 -->
    <CustomButton disabled>禁用按钮</CustomButton>

    <!-- 加载状态 -->
    <CustomButton loading>加载中</CustomButton>
  </div>
</template>

<script>
import { CustomButton } from "usecorehocks";

export default {
  components: {
    CustomButton,
  },
};
</script>

按钮属性

| 属性名 | 说明 | 类型 | 可选值 | 默认值 | | -------- | ------------------ | ------- | ----------------------------------------------------- | ------- | | type | 按钮类型 | string | default / primary / success / warning / danger / info | default | | plain | 是否为朴素按钮 | boolean | — | false | | round | 是否为圆角按钮 | boolean | — | false | | circle | 是否为圆形按钮 | boolean | — | false | | disabled | 是否禁用 | boolean | — | false | | loading | 是否显示加载中状态 | boolean | — | false |

按钮事件

| 事件名 | 说明 | 回调参数 | | ------ | -------------- | ------------ | | click | 点击按钮时触发 | event: Event |

按钮插槽

| 插槽名 | 说明 | | ------- | ---------- | | default | 按钮的内容 | | icon | 按钮的图标 |

Resize 指令

<template>
  <div v-resize="handleResize" class="resize-element">
    宽度: {{ width }}px, 高度: {{ height }}px
  </div>
</template>

<script>
export default {
  data() {
    return {
      width: 0,
      height: 0,
    };
  },
  methods: {
    handleResize(rect) {
      this.width = rect.width;
      this.height = rect.height;
    },
  },
};
</script>

<style>
.resize-element {
  width: 100%;
  height: 200px;
  border: 1px solid #ccc;
  resize: both;
  overflow: auto;
}
</style>

开发

# 安装依赖
pnpm install

# 构建库
pnpm build