Answer the question
In order to leave comments, you need to log in
Why are they not statically typed?
Good afternoon!
I ran into the following problem:
- I create a single component
- I initialize the interface
- for the sake of interest, I change the data type in the input array, I expect to see an error, but nothing happens, as if nothing had happened
PS The application installed create-nuxt-app typescript, the configs are not touched, like writing everything on the dock)
The data is fed to the component, it renders the whole thing
<input-fc
v-for="input in inputData"
:input="input"
:key="input.id"
/>
<template>
<div class="input">
<input
class="input__field"
:type="input.type"
:placeholder="input.placeholder"
>
<svg
v-if="input.icon"
class="icon"
>
<use xlink:href="~/static/icons/sprite.svg#search"></use>
</svg>
</div>
</template>
import Vue, { PropOptions } from 'vue'
interface InputData {
id: number
type: string
placeholder: string
icon?: string
}
export default Vue.extend({
name: 'Input',
props: {
input: {
type: Object,
required: true
} as PropOptions<InputData>
},
})
let inputData = [
{
id: 0,
type: 'text',
placeholder: 'Поиск в новостях',
icon: 1
}
];
Answer the question
In order to leave comments, you need to log in
I didn't understand. Do you want the TS to swear at the browser console at runtime? O_o
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question