props in components does not work interface - Nuxt and Vuejs

I can't work an object's interface inside a component using props.

Does anyone know how I can make it work?

PortariaInterface

export interface PortariaInterface {
  dataEntrada: string
  nfe?: {
    numero: string
}

Template

<Formulario :formulario="formulario" />

Ts

import {PortariaInterface} from '@/models/PortariaInterface'
import { Formulario } from '@/components/portaria'

export default Vue.extend({
  name: 'IndexPage',
  components: { Formulario },
  layout: 'portaria',
  data() {
    return {
      formulario: {} as PortariaInterface
    }
  }
})

Component

<el-col :xs="24" :sm="8" :md="8" :lg="6" :xl="4">
        <el-form-item label="Número NFe">
          <el-input v-model="formulario.nfe?.numero"></el-input>
        </el-form-item>
      </el-col>

export default Vue.extend({
  name: 'Formulario',
  props: ['formulario']
})

Error

TypeError: Cannot read properties of undefined (reading 'numero')


In this case you have two binding which should be done using v-model directive on your Formulario component as follows :

 <Formulario v-model="formulario" />

in this component bind the input using value and @input event:

<el-col :xs="24" :sm="8" :md="8" :lg="6" :xl="4">
        <el-form-item label="Número NFe">
          <el-input :value="numero" @input="onInput"></el-input>
        </el-form-item>
      </el-col>

export default Vue.extend({
  name: 'Formulario',
  props: ['value'],
  computed:{
   numero(){
     return this.value.nfe?.numero
   }

 },
 methods:{
  onInput(val){
    this.$emit('input',val)
  }
}
})