export default defineComponent({
name: 'MrComponent',
inject: ["mydata"],
computed: {
processedData() {
const mydata = this.mydata;
return mydata + 1; // Some handling of the data here
}
}
})
[vue-cli-service] TS2339: Property 'mydata' does not exist on type 'CreateComponentPublicInstance<{ [x: string & `on${string}`]: ((...args: any[]) => any) | undefined; } | { [x: string & `on${string}`]: ((...args: never) => any) | undefined; }, { chartOptions: { responsive: boolean; maintainAspectRatio: boolean; cutout: string; borderWidth: number; }; }, ... 15 more ..., {}>'.
[vue-cli-service] Property 'mydata' does not exist on type '{ $: ComponentInternalInstance; $data: {}; $props: { [x: string & `on${string}`]: ((...args: any[]) => any) | undefined; } | { [x: string & `on${string}`]: ((...args: never) => any) | undefined; }; ... 10 more ...; $watch(source: string | Function, cb: Function, options?: WatchOptions<...> | undefined): WatchStopHan...'.
[vue-cli-service] 41 | computed: {
[vue-cli-service] 42 | chartData() {
[vue-cli-service] > 43 | const mydata = this.mydata;
[vue-cli-service] | ^^^^^^^^
[vue-cli-service] 44 | }
[vue-cli-service] 45 | }
[vue-cli-service] 46 | })
<template>
{{ mydata }}
</template>
export default defineComponent<{ mydata: number }>({
inject: ['mydata'],
computed: {
processedData() {
// `this.mydata` is number
}
}
})
import { defineComponent, inject, computed } from 'vue'
export default defineComponent({
setup() {
const mydata = inject('mydata') as number
const processedData = computed(() => {
return mydata + 1
})
return {
processedData
}
}
})
declare module 'vue' {
interface ComponentCustomProperties {
fastdata: {
user: {
nome: string,
tel: string,
pts: number,
nivel: number,
proximo_nivel: number,
tot_kg: number,
coleta: Array<any>,
},
noticias: Array<any>,
},
}
}