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

hailuo

v1.1.3

Published

a light framework of frontend

Downloads

13

Readme

Hailuo.js

一款渐进式 MVVM 轻量级框架

1. 快速上手

  1. 通过cdn引入Hailuo
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/index.min.js"></script>
  1. 创建一个app对象
const App = H.createApp(`
    <div>
        My name is: 
        <span h-bind="test"></span>
    </div>
`);
  1. 设置响应式数据
App.useReactive({
    name: 'panda'
});
  1. 添加方法
App.register('handleClick', () => {
    console.log('this is a func');
    App.states.name = 'cat';
});
  1. 将该组件定义到全局Hailuo对象中
H.define('app', App);
  1. 当组件编译完成后,将组件添加到当前DOM树中
App.onMount(() => {
    console.log('this is mounted');
    document.querySelector('#root').appendChild(window.Hailuo.app);
});

2. API参考

Todo

3. 设计思想

Why we need Hailuo.js ?

在市面上流行了诸如vue、react等业界先进MVVM框架的现在,一套轻量的框架是否还有存在的必要呢?
答案是:有的。
如果我们是一个前端小白,当有一个项目摆在你面前时:how to do it ?如果使用jquery等早期技术,很难从中学习到现代前端框架的精髓且效率并不高,如果使用vue、react,从入门到上手应用需要一定时间的积累,学习成本相对较高。
就这样,应用MVVM思想且概念少容易上手——Hailuo.js应运而生。

  • MVVM

Hailuo的响应式基础是Object.defineProperty,通过观察者模式,进行依赖收集,在必要时进行更新,实现双向数据绑定(Two-way data binding)。

  • template

HTML部分由模板字符串直接生成至真实DOM,再通过递归对每一个元素添加Hailuo api的能力。

  • component

Hailuo是将所有声明过的组件都注册在window.Hailuo这个对象里,这样将有利于组件间的任意调用和外部组件的引入。