【问题标题】:Passing props in buefy/bulma modal component (nuxtjs)在 buefy/bulma 模态组件(nuxtjs)中传递道具
【发布时间】:2020-11-13 11:41:40
【问题描述】:

如何将道具传递给要用作 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 传递给组件?谢谢。

【问题讨论】:

    标签: nuxt.js bulma buefy


    【解决方案1】:

    我知道这是一个非常晚的回复,但希望这可以帮助其他人在未来看到这个。

    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,
          })
        },
      }
    

    【讨论】:

    • 谢谢你,李。我实际上自己找到了解决方案,但忘记发布答案。您的可能会帮助其他开发人员,因此非常感谢 ;-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-18
    • 1970-01-01
    • 1970-01-01
    • 2019-04-05
    • 2020-08-19
    • 2017-06-08
    相关资源
    最近更新 更多