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?
2
Answers
This is solution
you can use "emit event".
there is a demo.
parent:
child: