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

vue-directive-kit

v1.2.0

Published

A collection of vue directives.

Downloads

28

Readme

vue-directive-kit

banner

standard-readme compliant Conventional Commits Commitizen friendly

A collection of vue directive.

各种Vue自定义指令合集。

目录

安装

安装

npm i vue-directive-kit -D
# yarn add vue-directive-kit -D

全局注册 ES Module

import vueDirectiveKit from 'vue-directive-kit';
Vue.use(vueDirectiveKit);

CommonJs

const {default: vueDirectiveKit} = require('vue-directive-kit')
Vue.use(vueDirectiveKit)

Script Link

<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-directive-kit@latest/lib/vue-directive-kit.min.js"></script>

使用

imgLazyload

图片懒加载。当图片出现在浏览器视口才会加载。

<img v-img-lazyload="imgSrc">

imgPlaceholder

在图片加载完成前以占位内容过渡。支持以随机色或者指定图片占位。

指令默认作用于<img>标签。也可作用于其他普通元素标签,也就是图片显示为元素背景图,只需为指令添加修饰符bg即可。

作用于<img>标签:

<img v-img-placeholder="'http://api.dujin.org/bing/1920.php'" alt="">

作用于元素:

<div v-img-placeholder.bg="'http://api.dujin.org/bing/1920.php'"> </div>

若要以指定图片占位,需要传入一个字符串数组,数组第一项是图片地址,第二项是展位图地址。

作用于<img>标签:

<img v-img-placeholder="['http://api.dujin.org/bing/1920.php','https://www.baidu.com/favicon.ico']" alt="">

作用于元素:

<div v-img-placeholder.bg="['http://api.dujin.org/bing/1920.php','https://www.baidu.com/favicon.ico']" ></div>

infiniteScroll

监听滚动事件并处罚指定事件。可监听window的滚动事件或者指定元素的滚动事件。

监听window的滚动事件

<template>
    <div>
        <div class="wrapper" v-infinite-scroll="loadDataOpt">
            <ul class="list">
                <li class="item"> </li>
            </ul>
        </div>
    </div>
</template>

<script>
export default {
    data (){
        return {
            loadDataOpt:{
                loadfn: this.fetchData
            }
        }
    },
    methods:{
        fetchData(){
            console.log(`window滚动触发`);
        }
    }
}
</script>

监听指定元素的滚动事件。

<template>
    <div>
        <div class="wrapper" ref='wrapper'>
            <ul class="list"  v-infinite-scroll="loadDataOpt">
                <li class="item"> </li>
            </ul>
        </div>
    </div>
</template>

<script>
export default {
    data (){
        return {
            loadDataOpt:{
                loadfn: this.fetchData,
                ref: 'wrapper'
            }
        }
    },
    methods:{
        fetchData(){
            console.log(`指定元素滚动触发`);
        }
    }
}
</script>

鼠标跟随

在指令作用的元素范围内,生成一个鼠标跟随的元素。 可自定义元素样式及元素内容。

基本用法

基本用法

<div v-follower>case: v-follower</div>

自定义提示内容

自定义内容

<template>
    <div v-follower="options">case: v-follower</div>
</template>

<script>
export default {
    data() {
        return {
            options:{
                txt: "自定义内容"
            }
        };
    }
};
</script>

自定义样式

自定义样式

<template>
    <div v-follower="options">case: v-follower</div>
</template>

<script>
export default {
    data() {
        return {
            options:{
                txt: "自定义样式",
                style:{
                    "backgroundColor": "#38f",
                    "color": "#fff",
                }
            }
        };
    }
};
</script>

API

Maintainers

[@guthub handler](https://github.com/guthub handler)

Contributing

See the contributing file!

PRs accepted.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © 2019 slevin

code..