1.0.12 • Published 12 months ago

@linzhe_tools/number-scroll v1.0.12

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

@linzhe_tool/number-scroll

🚀 数字滚动组件

type Props = {
  // 动态改变这个数字字符串,即可实现滚动
  numberString: string
}

📝 使用方法

  • 浏览器使用
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/dayjs/1.11.7/dayjs.min.js"></script>
<script src="../packages/linzheTools/dist/linzheTools.umd.js"></script>
<link href="../packages/linzheTools/dist/linzheTools.css" rel="stylesheet" />
<div id="app">
  <number-scroll :number-string="numberValue"></number-scroll>
  <p>==============</p>
  <number-scroll :number-string="timeValue"></number-scroll>
</div>
<script>
  const { NumberScroll } = linzheTools
  const app = Vue.createApp({
    setup() {
      const { onMounted, ref, computed } = Vue
      const num = ref(100)
      const time = ref(Date.now())
      const numberValue = computed(() => num.value + '')
      const timeValue = computed(() => dayjs(time.value).format('HH:mm:ss'))
      onMounted(() => {
        setInterval(() => {
          num.value++
          time.value = Date.now()
        }, 1000)
      })
      return {
        numberValue,
        timeValue,
      }
    },
  })
  app.component('NumberScroll', NumberScroll)
  app.mount('#app')
</script>
  • 构建工具使用
# 方式1
npm i -S @linzhe_tools/number-scroll
# 方式2 推荐
npm i -S linzhe_tools
// main.ts
// 方式1
import '@linzhe_tools/number-scroll/dist/numberScroll.css'
// 方式2 推荐
import 'linzhe_tools/dist/linzheTools.css'
<!-- App.vue -->
<script lang="ts" setup>
  import dayjs from 'dayjs'
  // 方式1
  import NumberScroll from '@linzhe_tools/number-scroll'
  // 方式2 推荐
  import { NumberScroll } from 'linzhe_tools'

  import { onMounted, ref, computed } from 'vue'
  const num = ref(100)
  const time = ref(Date.now())
  const numberValue = computed(() => num.value + '')
  const timeValue = computed(() => dayjs(time.value).format('HH:mm:ss'))
  onMounted(() => {
    setInterval(() => {
      num.value++
      time.value = Date.now()
    }, 1000)
  })
</script>

<template>
  <NumberScroll :number-string="numberValue" />
  <p>==============</p>
  <NumberScroll :number-string="timeValue" />
</template>
1.0.9

12 months ago

1.0.11

12 months ago

1.0.10

12 months ago

1.0.12

12 months ago

1.0.8

12 months ago

1.0.7

12 months ago

1.0.6

12 months ago

1.0.2

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.1

1 year ago

1.0.0

1 year ago