3

I am trying to access a variable from a method, but I get : Property 'commentLikeVisible' does not exist on type '{ toggleCommentLikeVisible: () => void;

Here is my code:

<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>

I already tried toggleCommentLikeVisible() instead of toggleCommentLikeVisible: function() with the same result.

I have no idea what could be wrong in there.

5
  • 1
    it should work, i simulate your code here and it works fine Commented Oct 31, 2020 at 18:02
  • 1
    @BoussadjraBrahim I know, I don't understand why it does not work, could it be something with ionic ? ( it worked for me too for a day or so and then I started getting the error message with no reason ! ) Commented Oct 31, 2020 at 18:08
  • Could be some nasty internal nodejs cache. Could you delete node_modules and reinstall? Commented Oct 31, 2020 at 18:26
  • @Iyashi Just removed the Ionic project and created it again with no change. Error always exists Commented Oct 31, 2020 at 18:42
  • @TarikMokafih import the project into codesandbox because there must be something different in your project is the other project is working fine? Commented Oct 31, 2020 at 18:50

1 Answer 1

3

I think it is a warning/error because you have <script lang="ts"> if you edit the script tag, it appears to go away in the sample project I created <script>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.