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

@yhwang911/yh-directives

v0.1.4

Published

vue3+TS的常用指令

Downloads

4

Readme

介绍

​ vue3+ts的一些自定义指令

NPM官方源安装

npm i -g nrm
nrm use npm
npm i @yhwang911/yh-directives

使用

在mian.ts文件中引入
import { YhDirectivesPlugin } from '@yhwang911/yh-directives'
app.use(YhDirectivesPlugin)

鼠标划过 v-hover

<template>
  <div>
    <div class="box1" v-hover="{ backgroundColor: 'green', color: 'white' }">
      失败乃你之母
    </div>
  </div>
</template>

<script setup></script>

<style scoped>
.box1 {
  background-color: red;
  color: black;
  width: 200px;
  height: 200px;
  text-align: center;
  line-height: 200px;
}
</style>

v-infinite-scroll

<template>
  <div v-infinite-scroll="loadMoreData" class="box">
    <h3>InfiniteScrollDemo</h3>
  </div>
</template>

<script setup  lang="ts">
const loadMoreData = () => {
  console.log("loadMoreData");
};
</script>

<style lang="scss" scoped>
.box {
  width: 500px;
  height: 2000px;
  background-color: red;
}
</style>

v-lazy

<template>
  <div>
    <img
      v-lazy="'/vite.svg'"
      src="https://lekuzhima.club/cdn/images/kitty.gif"
      alt=""
    />

    <!-- <img src="/default.webp" alt="" /> -->

    <MyLazyImg
      class="mli"
      loading="/vite.svg"
      src="https://lekuzhima.club/cdn/images/dameizi.jpg"
    ></MyLazyImg>
  </div>
</template>

<script setup lang="ts">
import MyLazyImg from "@/components/MyLazyImg.vue";
</script>

<style lang="scss" scoped>
.mli {
  width: 100px;
}
</style>

v-pin

<template>
  <div class="pin-demo-root">
    <h3>PinDemo</h3>

    <!-- 吸顶效果 -->
    <h3 v-pin="50" v-pin:left="500">吸顶效果</h3>

    <!-- 吸底效果 -->
    <h3 v-pin:bottom="10" v-pin:right="100">吸附底部</h3>
    <h3 v-pin:left="0">吸附左边</h3>
    <h3 v-pin:right="50">吸附右边</h3>
  </div>
</template>

<script setup lang="ts"></script>

<style scoped lang="scss">
.pin-demo-root {
  width: 2000px;
  height: 2000px;
}
</style>

v-throttle

<template>
  <form action="#" v-throttle:submit="{ delay: 3000, handler: onSubmit }">
    <input type="text" placeholder="please enter username"/>
    <input type="password" placeholder="please enter password"/>
    <button>submit</button>
  </form>

  <button v-throttle:click="{ delay: 3000, handler: onClick }">click me</button>
</template>

<script setup  lang="ts">
const onSubmit = () => console.log("onSubmit");
const onClick = () => console.log("onClick");
</script>

<style lang="scss" scoped></style>

v-click-outside

<template>
  <div ref="popupRef" class="popup" v-click-outside="closePopup"></div>
</template>

<script setup lang="ts">
import { ref } from "vue";

const popupRef = ref(null);

const closePopup = () => {
  console.log("closePopup");
  (popupRef.value! as HTMLElement).classList.add("hidden");
};
</script>

<style lang="scss" scoped>
.popup {
  width: 600px;
  height: 400px;
  margin: 100px auto;
  border: 1px solid black;
}

.hidden {
  display: none;
}
</style>