gpt4 book ai didi

typescript - 无法从 Vue.js 中的方法访问数据(使用 Ionic)

转载 作者:行者123 更新时间:2023-12-05 03:48:00 25 4
gpt4 key购买 nike

我试图从一个方法访问一个变量,但我得到:类型“{ toggleCommentLikeVisible: () => void;”上不存在属性“commentLikeVisible”;

这是我的代码:

<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() 结果相同。

我不知道那里可能出了什么问题。

最佳答案

我认为这是一个警告/错误,因为你有 <script lang="ts">如果您编辑脚本标签,它似乎会在我创建的示例项目中消失 <script>

关于typescript - 无法从 Vue.js 中的方法访问数据(使用 Ionic),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64624732/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com