jeudi 30 novembre 2017

Vue.js - Declare a parent model on container

Is there any way of making this work?

Javascript:

const vm = new Vue({
  el: "#app",
  data: {
    invoice: {
      title: "test"
    }
  }
})

Pug:

#app
  // This works
  h2 
  input(v-model="invoice.title")

  // This is the thing I want to work
  div(v-model="invoice")
    span 

The thing I want to achieve is to say that "this whole container is bound to this object in the data. Every child of it should try to find the wanted data in that object and not in the root.

Let's say I have a lot of properties in the homeAddress object, then I don't want to have to write

.container
  span     
  span 

but only

.container(v-model="homeAddress")    
  span 
  span 

Aucun commentaire:

Enregistrer un commentaire