如何将 props 传递给要用作 Buefy/Bulma 模态模板的自定义组件?
这就是我声明组件的方式
import myCustomComponent from '~/components/myCustomComponent'
export default {
components: {
myCustomComponent ,
},
methods: {
openModal(prop) {
this.$buefy.modal.open({
parent: this,
// here I want to pass my 'prop' to myCustomComponent
// the equivalent of <myCustomComponent :prop='prop' />
component: myCustomComponent,
hasModalCard: true,
customClass: 'custom-class custom-class-2',
trapFocus: true,
})
},
}
如何将 prop 传递给组件?谢谢。
最佳答案
我知道这是一个非常晚的回复,但希望这对将来关注此问题的其他人有所帮助。
import myCustomComponent from '~/components/myCustomComponent'
export default {
components: {
myCustomComponent ,
},
methods: {
openModal(prop) {
this.$buefy.modal.open({
parent: this,
component: myCustomComponent,
props: {
// You can pass your props to the component here
prop
},
hasModalCard: true,
customClass: 'custom-class custom-class-2',
trapFocus: true,
})
},
}
关于nuxt.js - 在 buefy/bulma 模态组件中传递 props (nuxtjs),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64820278/