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

mini-mvvm

v0.0.10

Published

A mini lib to achieve mvvm. 一个轻量级的mvvm库。

Downloads

6

Readme

mini-mvvm

npm file size Build Status

A mini mvvm lib with virtual dom - mini-vdom.

基于 virtual dom - mini-vdom 的轻量级 mvvm 库 >_<#@!

适用于 ui 组件的构建依赖或小型项目,如果项目比较复杂,也许一个更加成熟的 mvvm 框架及其生态更适合你 🤠🤠

Installation

npm install mini-mvvm --save

包含了 .d.ts 文件,用起来毫无阻塞 >_<#@!

Live Example

MVVM - 功能演示

Development && Production

npm run dev:mini-mvvm 开发调试

npm run build 生产构建

Ability

  • [x] VNode 基于虚拟 dom: virtual dom - mini-vdom
  • [x] 数据监听
    • [x] datacomputed 变动监听
    • [x] 数组方法监听 push | pop | shift | unshift | splice | sort | reverse
  • [x] computed 计算属性
  • [x] 文本节点 数据绑定,可以是一段表达式
  • [x] attribute 数据绑定
    • [x] 支持绑定 data、computed,支持方法,可以是一段表达式
  • [x] 常用指令
    • [x] m-model 双向绑定。 支持 inputtextareaselect
    • [x] m-if 条件渲染。条件支持 datacomputed、一段表达式
    • [x] m-for 循环。(item,index) in arrayitem in array
  • [x] 事件绑定
    • [x] @click | @mousedown | ... 。可以使用 $event 占位原生事件
  • [x] watch 数据监听,详见下方示例
    • [x] 声明方式
    • [x] api 方式
  • [x] 生命周期
    • [x] created 组件创建成功,可以使用 this 得到 MVVM 的实例
    • [x] beforeMount 将要被插入 dom
    • [x] mounted 组件被添加到 dom,可以使用 this.$el 获取根节点 dom
    • [x] beforeUpdate 组件将要更新
    • [x] updated 组件更新完毕

Example

import MVVM from 'mini-mvvm'; // es module, typescript
// const MVVM from 'mini-mvvm'; // commonjs
// const MVVM = window['MiniMvvm']; // window

new MVVM({
    // 挂载的目标节点的选择器
    // 如果没有 template,就用这个节点作为编译模板
    el: '#app',
    template: `
    <div id="app">
        <div>{{ content }}</div>
    </div>
    `,
    // data
    data() {
        return {
            content: 'this is content.'
        };
    },
    computed: {}, // ...计算属性
    // ...hook,可以使用 this
    created() {
        // 使用api方式去watch
        this.$watch('key', (val, oldVal) => {}, { immediate: true });
    },
    mounted() {}, // ...hook,可以使用 this.$el
    methods: {}, // ...方法
    // ...数据监听
    watch: {
        // 声明方式1:
        watch1(val, oldVal) {},
        // 声明方式2:
        watch2: {
            immediate: true, // 立即执行
            handler(val, oldVal) {}
        }
    }
});

Enjoy it! :D