为什么工具提示在Vuejs的for循环中不起作用?

时间:2019-03-27 19:21:49

标签: vue.js tooltip

有一个提供工具提示的引导程序,因此在我的Vue组件中,我有for循环,在此循环中,Tooltip不起作用,而在循环外,它工作良好。为什么以这种方式表现? 这是我的代码

const app = new Vue({
  el: '#app',
  mounted(){
    $(document).ready(function(){

    $(function () {
      $('[data-toggle="tooltip"]').tooltip({html: true})
    });
    });
  }
});

<div v-for="(note, index) in notes">
 //so here it doesn't work
 <a href="#" data-toggle="tooltip" title="asd">link</a>
</div>

// Out of loop it works
<a href="#" data-toggle="tooltip" title="asd">link</a>

1 个答案:

答案 0 :(得分:0)

我想出了解决方案 https://vuejs.org/v2/api/#updated

我在组件中添加了

    updated: function () {
      this.$nextTick(function () {
        $(function () {
          $('[data-toggle="tooltip"]').tooltip({html: true})
        });
      })
    },