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

vue2-el-loading

v1.0.1

Published

:fire: Element loading directive based on vue2.x / 基于 vue2.x的loading 指令

Downloads

15

Readme

Loading 加载

特性

  • 开箱即用/极简使用
  • 体积:9k

文档 和 demo

:notebook_with_decorative_cover: :point_right:document & demo

:popcorn: 安装

npm i vue2-el-loading --save-dev

:zap:引入

main.js 文件中

import vue from "Vue";
import VLoading from "vue2-el-loading";
Vue.use(vLoading);

:sunny:全局配置

import vue from "Vue";
import VLoading from "vue2-el-loading";
Vue.use(vLoading, {
  color: "green", //也支持 rgb,hsl,16机制颜色码
  background: "yellow" //也支持 rgb,hsl,16机制颜色码
});

:crown:区域加载

可以在任意元素/UI 框架元素 上绑定 v-loading, 如下面vanttabs组件

::: details 点击查看代码

<template>
  <van-tabs v-model="activeName" @change="change" v-loading="isLoading">
    <van-tab title="标签 1" name="a">
      <p>内容1</p>
      <p>内容1</p>
      <p>内容1</p>
    </van-tab>
    <van-tab title="标签 2" name="b">内容 2</van-tab>
    <van-tab title="标签 3" name="c">内容 3</van-tab>
  </van-tabs>
</template>

<script>
export default {
  data() {
    return {
      activeName: "a",
      isLoading: true
    };
  },
  methods: {
    change() {}
  }
};
</script>

:::

:school_satchel:自定义

可局部自定义加载文案背景色,类名 在绑定了 v-loading 指令的元素上添加 element-loading-text 属性,其值会被渲染为加载文案,并显示在加载图标的下方。类似地,element-loading-background 属性设定背景色值。element-loading-custom-class额外增加一个自定义类名 ::: tip 暂不支持自定义图标 :::

::: tip 局部配置优先级高于全局配置 :::

::: details 点击查看代码

<template>
  <van-tabs
    v-model="activeName"
    @change="change"
    v-loading="isLoading"
    element-loading-text="拼命加载中.."
    element-loading-color="#32CD32"
    element-loading-background="rgba(0, 0, 0, 0.8)"
    element-loading-custom-class="customClass"
  >
    <van-tab title="标签 1" name="a">
      <p>内容1</p>
      <p>内容1</p>
      <p>内容1</p>
    </van-tab>
    <van-tab title="标签 2" name="b">内容 2</van-tab>
    <van-tab title="标签 3" name="c">内容 3</van-tab>
  </van-tabs>
</template>

<script>
export default {
  data() {
    return {
      activeName: "a",
      isLoading: true
    };
  },
  methods: {
    change() {}
  }
};
</script>

:::

:unicorn:全屏 loading

当使用指令方式时,全屏遮罩需要添加 fullscreen 修饰符(遮罩会插入至 body 上),此时若需要锁定屏幕的滚动,可以使用 lock 修饰符;

<template>
  <div>
    <van-button
      type="primary"
      v-loading.fullscreen="isLoading"
      @click="openFullScreen1"
      >点击开启全屏loading</van-button
    >

    <van-button
      type="primary"
      v-loading.fullscreen.lock="isLoading2"
      @click="openFullScreen2"
      >点击开启全屏loading,并且锁定屏幕滚动</van-button
    >
  </div>
</template>

<script>
export default {
  data() {
    return {
      isLoading: false,
      isLoading2: false
    };
  },
  methods: {
    openFullScreen1() {
      this.isLoading = true;
      setTimeout(() => {
        this.isLoading = false;
      }, 2000);
    },
    openFullScreen2() {
      this.isLoading2 = true;
      setTimeout(() => {
        this.isLoading2 = false;
      }, 2000);
    }
  }
};
</script>

<style></style>

:::