Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two components, TimeLine.vue(Parent) and SuspendedMemo.vue(Child)

TimeLine.vue(Parent)

computed: {
    optionsData () {
        groupTemplate: (item, element, data) => {
          if (!item) return
          var container = document.createElement('div')
          if (item.isDisable !== true) container.setAttribute('class', 'enable')
          var i = document.createElement('i')
          // click
          i.addEventListener('click', () => {
            // itemのidを取得してSuspendedMemoに渡す
            var itemId = item.id
            const url = `/shop/${this.selectedShopId}/room/${itemId}/suspend_memo`
            console.log('Timeline of URL’, url)
            this.data = item.suspendedReserveMemo
            this.openMemo()
          })
          i.setAttribute('class', 'v-icon notranslate mr-2 mdi mdi-close-circle theme--light pink--text')
          container.appendChild(i)
          var span = document.createElement('span')
          span.innerHTML = item.content
          container.appendChild(span)
          return container
        }
      }
      return _.merge({}, base, this.options)
    }
  },


When I click ↑, how to send variable ‘url’ to SuspendedMemo.vue(Child) component?

What I have tried:

How to send variable from Parent to Child component when I use "click" at Vue.js?
Posted

1 solution

If I were looking to do this, I would be considering Slots or Props in Vue. For this particular case, where you don't appear to be worried so much about the visual aspect being affected in the child, I would stick with Props. You can get an example of props here[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900