【发布时间】:2023-02-16 20:54:12
【问题描述】:
我是 TypeScript 的新手,现在我正面临一些“类型”问题。 我试图找到类似的问题,但他们无法帮助我。
我的 webpack 返回了 3 个错误:
-
TS2339: Property 'current_category' does not exist on type '{ filterByCategory: (array: any) => any; }'。 -
TS2339: Property 'filterByCategory' does not exist on type '{ filteredProducts: () =>任何; }'。 -
TS2339:Property 'services' does not exist on type '{ filteredProducts: () => any; }'。我的代码:
<script lang="ts"> import axios from "axios"; import {ref} from "vue"; import type {WP_REST_API_Posts} from 'wp-types'; declare var wpFrontendLocalizer: any; export default { name: 'HomePage', components: {}, methods: { filterByCategory: function(array: any){ return array.filter((service: any) => service.type == this.current_category) ; } }, data() { return { current_category:"xxx", services:[ ] } }, computed:{ filteredProducts: function(){ return this.filterByCategory(this.services); } }, mounted() { }, } </script>
【问题讨论】:
标签: typescript vue.js