You may have an infinite update loop in a component render function

后端 未结 3 609
野趣味
野趣味 2020-12-29 02:09

I\'m new to VueJS, I\'ve got warning from Vue,

[Vue warn]: You may have an infinite update loop in a component render function. 

When i us

3条回答
  •  孤独总比滥情好
    2020-12-29 02:34

    You can get this error if you call a function instead of pass a function in a vue directive. Here is an example:

    I made a custom directive to load data via AJAX when a boostrap tab is displayed.

    This is bad:

     v-on-show-bs-tab="getFirstPageSites()"
    

    Here, vue appears to call the function (or rather evaluate the expression) and pass the result to the directive.

    This is good:

     v-on-show-bs-tab="getFirstPageSites"
    

    Here I am passing the function by name such that I can call it in the directive.

提交回复
热议问题