Gumball12 / mvvm-in-js

simplest mvvm application example with vanilla js

Home Page:https://gumball12.github.io/mvvm-in-js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MVVM in JS

MVVM Wrapped HTMLElement

Constructor

  • html: html template string
  • data: data model
  • methods: methods
  • watch: watchers
  • created: callback that invoked when element is created
  • mounted: callback that invoked when element is connected into the DOM

Properties

  • $root: shadow dom root
  • $data: data model
  • $watcher: data watcher
  • $methods: methods
  • $emit: dispatch custom event
  • $ref: referenced elements

DOM Attribute usages

  • m-bidata-<child-data-name>="<dataName>": two-way data binding (via data model)
  • m-data-<child-data-name>="<string type value>": set data
  • m-prop-<child-property-name-to-update>="<dataName>": property binding
  • m-attr-<child-attribute-name-to-update>="<dataName>": attribute binding
  • m-ref="<refName>": register a reference to an element
  • @<eventname>="<methodName>": add event listener

Install

# clone this repo
git clone https://github.com/Gumball12/mvvm-in-js.git
cd mvvm-in-js

# start local server
live-server

About

simplest mvvm application example with vanilla js

https://gumball12.github.io/mvvm-in-js/

License:GNU General Public License v3.0


Languages

Language:JavaScript 96.5%Language:HTML 2.1%Language:CSS 1.4%