How do you use the interface to Vue.js?
-
I have an interface.
export interface TaskInterface{ name: string description1: string time: string }
import { TaskInterface } from '@/types/task.interface'
and variable
data () { return { tasks: [{ name: 'Create app', description1: 'Use smth ', time: '02.12.2021' }, { name: 'Fix bugs', description1: 'Fix all bugs', time: '02.12.2021' }] as TaskInterface[]
But I don't make a mistake if I do "name : 123,
How do you use the interface to Vue.js?
-
The mistake arises because you indicated the type of variable
name
Totalstring
And you're making a mistake trying to make a mannumber
♪ Based on this, if you're getting an interference-related error, this code works and the interface is assigned to the object. If variablename
may contain several data types, they shall be described in the interface, for example:export interface TaskInterface { name: string | number }