用ts写一个组件的时候,遇到了Property ‘increment’ does not exist on type 'Add’的红点儿报错,但神奇的是竟然还能正常运行。
在参考一些正确的代码后,有两个解决方案。
-
在
export default class Add extends Vue {}
里面定义对应的Prop:import { Component, Vue, Prop } from “vue-property-decorator”;
import { mapState } from “vuex”;@Component({
computed: {
…mapState({
sum: (state) => (state as Record<string, number>).sum,
}),
},
methods: {
//…mapActions([“Add”, “Subtract”]),
increment() {
this.KaTeX parse error: Exp