【发布时间】:2021-02-13 21:09:01
【问题描述】:
我正在尝试从方法访问变量,但我得到:
Property 'commentLikeVisible' does not exist on type '{ toggleCommentLikeVisible: () => void;
这是我的代码:
<template>
<div
class="moments-item"
data-index="0"
>
<div class="item-right">
<div class="item-ft">
<div
class="item-reply-btn"
@click="toggleCommentLikeVisible"
>
<span class="item-reply" />
</div>
<CommentLikeModal
v-if="commentLikeVisible"
/>
</div>
</div>
</div>
</template>
<script lang="ts">
import CommentLikeModal from '@/components/CommentLikeModal.vue';
export default {
name: 'MomentItem',
components: {
CommentLikeModal
},
data() {
return {
commentLikeVisible: false
}
},
methods: {
toggleCommentLikeVisible: function() {
this.commentLikeVisible = !this.commentLikeVisible;
}
}
}
</script>
我已经尝试过toggleCommentLikeVisible() 而不是
toggleCommentLikeVisible: function() 结果相同。
我不知道那里可能有什么问题。
【问题讨论】:
-
它应该可以工作,我模拟你的代码here 它工作正常
-
@BoussadjraBrahim 我知道,我不明白为什么它不起作用,可能是 ionic 的东西吗? (它也为我工作了一天左右,然后我开始无缘无故地收到错误消息!)
-
可能是一些讨厌的内部 nodejs 缓存。你能删除
node_modules并重新安装吗? -
@Iyashi 刚刚删除了 Ionic 项目并再次创建它,没有任何更改。错误总是存在
-
@TarikMokafih 将项目导入codesandbox,因为您的项目中必须有一些不同的东西,其他项目工作正常吗?
标签: typescript vue.js ionic-framework