# Examples

# Green

Edit Vue Template

# Dash Item Child Component Example:

Edit Vue Template

Child Component Code Below:

<template>
  <div class="content">
    Item ID by Inject: {{ id }}
    <br>
    Item ID by Prop: {{ itemId }}
  </div>
</template>

<script>
export default {
  inject: { $item: { default: null } },
  props: {
    itemId: { type: [Number, String] }
  },
  computed: {
    itemByinject() {
      if (this.$item) {
        return this.$item();
      }
      return null;
    },
    id() {
      if (this.itemByinject) {
        return this.itemByinject.id;
      }
      return "";
    }
  }
};
</script>

<style>
.content {
  height: 100%;
  width: 100%;
  border: 2px solid #42b983;
  border-radius: 5px;
  background-color: #42b9833d;
}
</style>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Last Updated: 3/9/2020, 10:21:26 AM