P
P
PHVNTOW2021-09-23 23:44:24
Vue.js
PHVNTOW, 2021-09-23 23:44:24

How to pass data from different components?

Can't pass Input value from App component to Item component.

Tried everything I could find on google.

------------------ App -------------------

import item from './components/Item.vue'

export default {
  name: "App",
  components: {
    item
  },
  data() {
    return {
      ipnutValue: '',
      items: []
    }
  },
  methods: {
    addNote() {
      this.items.push("item")
      this.ipnutValue = this.itemTitle
      console.log(this.ipnutValue)
      this.ipnutValue = ""
      console.log('Note was create')
    }
  },
};

------------------- Item -------------------

export default {
  name: "item",
  data() {
    return {
      itemTitle: '',
      itemStatus: 'isActive',
      delItem: true
    }
  },
  methods: {
    statusFun: function () {
      if(this.itemStatus === 'isActive') {
        this.itemStatus = 'isDone'
      } else {
        this.itemStatus = 'isActive'
      }
      console.log('Status Working')
    },
    DelFun() {
      console.log('Del BTN Working')
    }
  }
};

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
Wispik, 2021-09-23
@PHVNTOW

props

A
Alex_mos, 2021-09-24
@Alex_mos

props or vuex depending on how the item component is positioned

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question