无法在模式vuejs中添加输入字段

zbdgwd5y  于 2023-05-01  发布在  Vue.js
关注(0)|答案(1)|浏览(136)

我一直在尝试添加一个新的领域内的模态弹出,但它似乎不工作。我可以设法显示输入,但我不能得到它的值发送后。
未收到付款的订单组件中

  1. <td class="width-150">
  2. <payment-not-received-order-actions
  3. :row="row"
  4. @markAsPaidAction="confirmMarkAsPaid(row)"
  5. />
  6. </td>
  7. confirmMarkAsPaid (row) {
  8. this.$modal.show('dialog', {
  9. title: this.$t('payment_not_received_orders.modal.title'),
  10. component: PaymentNotReceivedInput,
  11. buttons: [
  12. {
  13. title: this.$t('payment_not_received_orders.modal.ok_button'),
  14. handler: () => {
  15. const requestBody = {
  16. note: this.$refs.paymentNotReceivedInput.note || ''
  17. }
  18. this.markAsPaid(row.id, requestBody)
  19. this.$modal.hide('dialog')
  20. }
  21. },
  22. {
  23. title: this.$t('payment_not_received_orders.modal.cancel_button')
  24. }
  25. ]
  26. })
  27. },

未收到付款订单操作组件中:

  1. <div class="text-right">
  2. <button
  3. type="button"
  4. class="btn btn-default btn-md margin-3"
  5. @click="$emit('markAsPaidAction')"
  6. >
  7. <i class="fa fa-eur" aria-hidden="true" />
  8. {{ $t('orders.orders_action.mark_as_paid') }}
  9. </button>
  10. </div>

在payment-not-received-input中(我添加了该字段):

  1. <template>
  2. <div>
  3. <label for="note">{{ $t('payment_not_received_input.modal.note_label') }}</label>
  4. <textarea id="note" v-model="note" ref="note"></textarea>
  5. </div>
  6. </template>
  7. <script>
  8. export default {
  9. name: 'payment-not-received-input',
  10. data () {
  11. return {
  12. note: ''
  13. }
  14. },
  15. mounted() {
  16. this.note = '';
  17. }
  18. }

这条线似乎根本不起作用:

  1. this.$refs.paymentNotReceivedInput

那么,如何在vuejs的模式弹出窗口中添加输入字段呢?

7y4bm7vi

7y4bm7vi1#

要使this.$refs.paymentNotReceivedInput工作,必须将引用放在payment-not-received-input组件上
我不知道你的payment-not-received-input组件在哪里使用。应该这样用

  1. <payment-not-received-input ref="paymentNotReceivedInput" ....

相关问题