Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. <!-- language: lang-html -->
  2. <p>£{{plant_price}}</p>
  3.  
  4. <div v-if="selected.plant.variations.length > 0 ">
  5. <select v-model="selected.plant.selected_variation" class="form-control">
  6. <!-- inline object literal -->
  7. <option v-for="(variation, i) in selected.plant.variations" :selected="variation.id == selected.plant.selected_variation ? 'selected' : ''":value="variation.id">
  8. {{variation.name}}
  9. </option>
  10. </select>
  11. </div>
  12.  
  13. <!-- language: lang-js -->
  14. var app = new Vue({
  15. el: '#vueApp',
  16. data: {
  17. selected: {
  18. type: {a: '' , b: ''},
  19. vehicle: '',
  20. plant: {
  21. }
  22. },
  23. computed: {
  24. plant_price: function() {
  25. if (this.selected.plant.variations.length > 0 ) {
  26. var variant = _.find(this.selected.plant.variations, {id: this.selected.plant.selected_variation });
  27. return variant.price;
  28. } else {
  29. return this.selected.plant.price;
  30. }
  31. }
  32. ...
  33.  
  34. selected:Object
  35. type:Object
  36. vehicle: "Truck"
  37. plant:Object
  38. id:26
  39. price:"52"
  40. regular_price:"100"
  41. selected_variation:421
  42. variations:Array[2]
  43. 0:Object
  44. id:420
  45. name:"small"
  46. price:52000
  47. regular_price:52000
  48. 1:Object
  49. etc...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement