简体   繁体   中英

Vue.js set data in other component without event

Currently I'm using Laravel Nova . Behind the scenes it's using vue.js. I've made a custom vue component that need's to change data within another component.

That other component lives in the node_modules directory so I can't change the component code. The component is not using events so I can't change the data with that.

I was wondering is it possible to change data within another component without using events?

I don't know the code of the component where you want to set the data.
But if it has a ref you can do something like:

updateData: function() {
  this.$refs.xyComponent.clicked = true
}

Notice that the $refs are only populated after the render process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM