@charrue/vump
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-alpha.7 • Public • Published

vump

🚴类Vue语法的微信小程序轻量级工具库,基于原生开发标准

特性

  • [x] 基于原生开发(利用Component)
  • [x] 基于@vue/reactivity实现了computed、watch功能(对Proxy做了polyfill)
  • [x] 逻辑复用mixins
  • [x] TypeScript支持
  • [x] 基于wxstore的data diff
  • [x] 插件功能
  • [x] Composition API

下载

npm install @charrue/vump

使用

基础使用

import { createComponent, ref, computed, watch, onCreated, onMounted } from "@charrue/vump";

createComponent({
  props: {
    default: {
      type: Number,
      default: 0
    }
  },
  setup(props) {
    const count = ref(props.default);
    const nextCount = ref(1);

    const sign = computed(() => {
      if (count.value === 0) return "";
      return count.value > 0 ? "+" : "-";
    });
    watch(count, (val) => {
      nextCount.value = val + 1;
    });

    const onIncrease = () => {
      count.value += 1;
    }
    const onDecrease = () => {
      count.value -= 1;
    }

    onCreated(() => {
      console.log("component created")
    })
    onMounted(() => {
      console.log("component attached")
    })

    return {
      count,
      sign,
      nextCount,

      onIncrease,
      onDecrease,
    }
  }
});

Package Sidebar

Install

npm i @charrue/vump

Weekly Downloads

1

Version

1.0.0-alpha.7

License

MIT

Unpacked Size

37.1 kB

Total Files

5

Last publish

Collaborators

  • charrue