-
-
Save aok-solutions/a8cca14b476a6f7c9a161b34f7b1edb1 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/kiqozuricu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.16/vue.js"></script> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<table> | |
<tbody> | |
<template id="parent-template"> | |
<child v-for="item in inventory" :inventory_item="item"></child> | |
</template> | |
</tbody> | |
</table> | |
<script id="jsbin-javascript"> | |
Vue.component('child', { | |
template: '<tr><td>{{ inventory_item.sku }}</td><td>{{ inventory_item.location }}</td><td>{{ inventory_item.quantity }}</td></tr>', | |
props: ['inventory_item'], | |
data: function () { | |
return { } | |
}, | |
compiled: function () { | |
console.log(this.inventory_item) // passed from parent | |
} | |
}); | |
var parent = new Vue({ | |
el: '#parent-template', | |
data: function () { | |
return { | |
inventory: [ | |
{ | |
'sku': '123', | |
'location': 'NYC', | |
'quantity': 5000 | |
}, | |
{ | |
'sku': '345', | |
'location': 'Chicago', | |
'quantity': 8000 | |
}, | |
{ | |
'sku': '678', | |
'location': 'LA', | |
'quantity': 3000 | |
} | |
] | |
} | |
} | |
}); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">Vue.component('child', { | |
template: '<tr><td>{{ inventory_item.sku }}</td><td>{{ inventory_item.location }}</td><td>{{ inventory_item.quantity }}</td></tr>', | |
props: ['inventory_item'], | |
data: function () { | |
return { } | |
}, | |
compiled: function () { | |
console.log(this.inventory_item) // passed from parent | |
} | |
}); | |
var parent = new Vue({ | |
el: '#parent-template', | |
data: function () { | |
return { | |
inventory: [ | |
{ | |
'sku': '123', | |
'location': 'NYC', | |
'quantity': 5000 | |
}, | |
{ | |
'sku': '345', | |
'location': 'Chicago', | |
'quantity': 8000 | |
}, | |
{ | |
'sku': '678', | |
'location': 'LA', | |
'quantity': 3000 | |
} | |
] | |
} | |
} | |
});</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vue.component('child', { | |
template: '<tr><td>{{ inventory_item.sku }}</td><td>{{ inventory_item.location }}</td><td>{{ inventory_item.quantity }}</td></tr>', | |
props: ['inventory_item'], | |
data: function () { | |
return { } | |
}, | |
compiled: function () { | |
console.log(this.inventory_item) // passed from parent | |
} | |
}); | |
var parent = new Vue({ | |
el: '#parent-template', | |
data: function () { | |
return { | |
inventory: [ | |
{ | |
'sku': '123', | |
'location': 'NYC', | |
'quantity': 5000 | |
}, | |
{ | |
'sku': '345', | |
'location': 'Chicago', | |
'quantity': 8000 | |
}, | |
{ | |
'sku': '678', | |
'location': 'LA', | |
'quantity': 3000 | |
} | |
] | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment