Skip to content
/ vump Public

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

Notifications You must be signed in to change notification settings

charrue/vump

Repository files navigation

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

npm

特性

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

下载

npm install @charrue/vump @charrue/reactivity -S

使用

基础使用

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,
    }
  }
});

更多使用请查看文档

About

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

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published