Git Product home page Git Product logo

mj.js's Introduction

mj.js

受 Mithril 启发的基于 jQuery 实现的极简框架。

简介

本框架只有两个小函数共约 10 行代码,但使用起来的便利程度接近于 Mithril, 易学、易用、易理解,非常适用于小型项目。

为什么要模仿 Mithril ?

  • 在使用 jQuery 写小项目的时候,通常习惯写一部分 HTML, 然后再写 js 去操作 DOM, 但这样做不方便做组件。
  • 模仿了 Mithril 之后,完全不写 HTML, 一切都是 js, 因此非常轻松实现组件化,并且实际效果非常好,组件可以相互交流、可以嵌套、可以复用。
  • 使用时,完完全全是 jQuery 的基本操作,对于已经会用 jq 的人来说,学习成本接近零。

安装使用

  • 本框架只有两个小函数,就在本仓库的 mj.js 文件里,直接复制,粘贴到自己的代码里使用即可。
  • 更具体的使用方法请看本仓库 examples 文件夹里的示例。
  • 更多简介请看宣传文案 https://v2ex.com/t/758276

误解

  • 我发现很多人误解了这个框架,只把注意力集中到生成 HTML 方面,不,这不是本框架的重点。
  • 本框架的重点是组件,组件是真组件,本框架的组件不仅可以生成 HTML, 并且在生成 HTML 之后还能:
    1. 通过调用组件本身的方法来使组件发生变化
    2. 通过组件的 id 来访问组件,从而实现组件之间的交流
  • 在 examples/userlist.html 的注释中有更具体的说明。

mj.js's People

Contributors

ahui2016 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.