Examples

Data and Views

A showcase a simple app using just data and a view.

Note: models or controllers are not required to create an application

  • data/initial.yml

    config:
      ui:
        mount:
          el: '#app'
          component: 'foobarCounter'
    
    foo:
        bar: 123
    
  • data/schema.yml

    foo:
        type: object,
        properties:
            bar: integer
    
  • view/inc.js
    module.exports = {
        name: 'foobarCounter',
        args: {
            no: '/foo/bar'
        },
        fn: args => '<span></span>'
    }
    
  • app.html

  • <div id="app"></div>
    
  • app.js

    import jsonmvc from 'jsonmvc'
    
    jsonmvc({
        views: {
            inc: require('view/inc.js')
        },
        data: {
            initial: require('data/initial.yml'), // example with webpack yml preloader
            schema: require('data/schema.yml')
        }
    })
    

results matching ""

    No results matching ""