GithubHelp home page GithubHelp logo

mvvm's Introduction

mvvm

一个简单的mvvm的实现,参考Vue中的模板编译、数据绑定和render函数的生成。

不用安装任何依赖,直接npm start, 然后访问http://127.0.0.1:9000即可查看效果。

src文件夹中是具体mvvm的实现,主要有三个文件:

  • mvvm.js是框架入口文件,其中包括了调用oberser监听对象,根据ast生成render函数,并执行render函数生成最终的dom内容。
  • observe.js中,就是对data数据进行监听。
  • parse中,是把传入的template字符串解析为一个ast,供生成render时候使用。

备注: mvvm1.js中是一个失败的例子。为了简单,本来不准备像Vue中那样把ast解析为render函数,而是直接根据ast生成dom树。但是在处理嵌套for循环以及事件传参等情况时,绑定数据获取的作用域处理十分困难。最终放弃。

server文件夹中是简单的服务端实现,监听端口,并根据path及后缀名返回相应的内容。

mvvm's People

Contributors

liutao 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.