Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. import Post from './components/Post.vue';
  2.  
  3. new Vue ({
  4. el: 'body',
  5.  
  6. components: { Post },
  7.  
  8. data: {
  9. limitByNumber: 4
  10. }
  11. });
  12.  
  13. <template>
  14. <div class="Post" v-for="post in list | limitBy limitByNumber">
  15. <!-- Blog Post -->
  16. ....
  17. </div>
  18. </template>
  19.  
  20.  
  21. <!-- script -->
  22. <script>
  23. export default {
  24. props: ['list', 'limitByNumber'],
  25.  
  26.  
  27. created() {
  28. this.list = JSON.parse(this.list);
  29. }
  30.  
  31. }
  32. </script>
  33.  
  34. <template>
  35. <div class="Post" v-for="post in list | limitBy this.$parent.limitByNumber">
  36. </div>
  37. </template>
  38.  
  39. <template>
  40. <post :limit="limitByNumber"></post>
  41. </template>
  42. <script>
  43. export default {
  44. data () {
  45. return {
  46. limitByNumber: 4
  47. }
  48. }
  49. }
  50. </script>
  51.  
  52. <template>
  53. <div class="Post" v-for="post in list | limitBy limit">
  54. <!-- Blog Post -->
  55. ....
  56. </div>
  57. </template>
  58.  
  59.  
  60. <!-- script -->
  61. <script>
  62. export default {
  63. props: ['list', 'limit'],
  64.  
  65.  
  66. created() {
  67. this.list = JSON.parse(this.list);
  68. }
  69.  
  70. }
  71. </script>
  72.  
  73. export default {
  74. name: 'LayoutDefault'
  75.  
  76. getParent(name){
  77. let p = this.$parent;
  78. while(typeof p !== 'undefined'){
  79. if(p.$options.name == name) {
  80. return p;
  81. }else {
  82. p = p.$parent;
  83. }
  84. }
  85. return false;
  86. }
  87.  
  88. this.getParent('LayoutDefault').myVariableOrMethod
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement