🚴类Vue语法的微信小程序轻量级工具库,基于原生开发标准
- 基于原生开发(利用
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,
}
}
});
更多使用请查看文档。