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

wj-loading-vue

v2.0.0

Published

vue指令,兼容vue2和vue3,支持自定义指令名及多种动画。

Downloads

348

Readme

wj-loading-vue

当前为2.X文档。(1.X文档

NPM Version NPM Downloads NPM License

基于wj-loading构建的vue指令,兼容vue2和vue3,支持自定义指令名及多种动画。

安装

  • npm install wj-loading-vue
  • yarn add wj-loading-vue

引入

vue3

import {createApp} from 'vue'
import App from './App.vue'
// 引入样式
import 'wj-loading-vue/dist/wj-loading-vue.css'
import Loading from 'wj-loading-vue'

createApp(App).use(Loading).mount('#app')

vue2

import Vue from 'vue'
import App from './App.vue'
// 引入样式
import 'wj-loading-vue/dist/wj-loading-vue.css'
import Loading from 'wj-loading-vue'

Vue.use(Loading)

new Vue({
  render: h => h(App),
}).$mount('#app')

自定义指令名

import {createApp} from 'vue'
// 引入样式
import 'wj-loading-vue/dist/wj-loading-vue.css'
import Loading from 'wj-loading-vue'

// 默认指令名为loading
createApp(App).use(Loading, {name: 'wj-loading'})

指令名冲突

若引入了element ui等组件可能会导致相同指令名冲突,解决办法:

  • 后引入的指令会覆盖先引入的指令
  • 自定义指令名

示例

示例一


<template>
  <div style="width: 500px; height: 500px;" v-loading:[arg]="loading"></div>
</template>

<script setup>

  import {ref} from 'vue';

  const arg = ref('BounceLoading')
  const loading = ref(true)

  setTimeout(() => {
    loading.value = false
  }, 2000)

</script>

arg支持wj-loading中定义的动画类型,支持动态修改动画类型,缺省值为BounceLoading,支持驼峰,v-loading:CubesLoadingv-loading:cubesLoading 效果相同。

当绑定的值为布尔类型时,会使用对应动画类型的默认参数,若想自定义参数可以参考示例二示例三,动画类型和对应支持的参数请查看wj-loading

示例二


<template>
  <div style="width: 500px; height: 500px;" v-loading:CmSpinnerLoading="loading"></div>
</template>

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

  const loading = ref({
    enable: true, // 动画开关
    option: { // 对应动画参数请查看wj-loading文档
      background: 'rgba(0,0,0,.5)',
    }
  })

  setTimeout(() => {
    // loading.value = {...loading.value, enable: false}
    loading.value = {
      enable: false, // 动画开关
      option: { // 对应动画参数请查看wj-loading文档
        background: 'rgba(255,255,255,.5)',
      }
    }
  }, 2000)

</script>

当前这种使用方式,参数更新时需对整个对象重新赋值,否则指令无法监听到改变。

示例三


<template>
  <div style="width: 500px; height: 500px" v-loading:CmSpinnerLoading="{
    enable: loading,
    option: {
      background: background,
      zIndex: 666
    }
  }"></div>
</template>

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

  const loading = ref(true)
  const background = ref('rgba(0,0,0,0.5)')

  setTimeout(() => {
    background.value = 'rgba(255,255,255,0.5)'
  }, 2000)

  setTimeout(() => {
    loading.value = false
  }, 5000)

</script>

示例四

import 'wj-loading-vue/dist/wj-loading-vue.css'
import {Loading} from 'wj-loading-vue'

new Loading.TextLoading({
  element: document.body,
  background: 'rgba(255, 255, 255, .8)',
  immediate: true
})

支持wj-loading原生使用方法。