Skip to content

Instantly share code, notes, and snippets.

@wilcorrea
Forked from k33g/index.html
Created August 9, 2016 20:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilcorrea/1f1ce12aa5efc2ac60428ac5b4650a47 to your computer and use it in GitHub Desktop.
Save wilcorrea/1f1ce12aa5efc2ac60428ac5b4650a47 to your computer and use it in GitHub Desktop.
Vue.js + ES6
<div id="demo">
<h1>{{bob.fields.firstName}} {{bob.fields.lastName}}</h1>
</div>
<ul id="humans-list">
<li v-repeat="humans">
{{fields.firstName}} {{fields.lastName}}
</li>
</ul>
class Human {
constructor (arg={firstName:"John", lastName:"Doe"}) {
this.fields = arg;
}
get (fieldName) {
return this.fields[fieldName];
}
set (fieldName, value) {
this.fields[fieldName] = value;
return this;
}
}
class Demo extends Vue {
constructor () {
var properties = {
el: '#demo',
data: {
bob: new Human({firstName:"Bob", lastName:"Morane"})
}
};
super(properties)
}
}
class HumansList extends Vue {
constructor (collection) {
this.collection = collection;
super({
el: "#humans-list", data: collection
})
}
}
let demo = new Demo()
let humansList = new HumansList({
humans:[
new Human(),
new Human({firstName:"Jane", lastName:"Doe"})
]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment