MostafaGamal
9 months ago
31
3
Vue

In Vue.js, does it make a difference if I call a function with parentheses?

Posted 9 months ago by MostafaGamal

In the following code

<script>
    import reply from './reply.vue';
    import NewReply from './NewReply.vue';

    export default {
        data(){
            return{
                items: [],
                dataSet: false,
            }
        },
        components:{reply, NewReply},
        created(){
            this.fetch();
        },
        methods:{
            remove(index){
                this.items.splice(index, 1);
            },
            addReply(reply){
                this.items.push(reply);
            },
            fetch(){
                axios.get(this.getUrl()).then(this.refresh);
            },
            refresh(response){
                this.items = response.data.data;
                this.dataSet = response.data;
            },
            getUrl(){
                return location.pathname + '/replies';
            }
        },

    }
</script>

does it make a difference if I call this.fetch() without parentheses this.fetch? The same question for this.getUrl()? why not calling this.refresh with parentheses ?

can any one help me to understand the difference ?

Please sign in or create an account to participate in this conversation.