代码之家  ›  专栏  ›  技术社区  ›  niclas_4

nuxt中的注入函数

  •  2
  • niclas_4  · 技术社区  · 6 年前

    我尝试在插件中注入一个函数

    插件程序

    import Vue from 'vue'
    import mediumZoom from 'medium-zoom'
    
    Vue.prototype.$mediumZoom = mediumZoom()
    

    当我试图加载我的页面时,它会无限地加载,最终页面不会做出反应,如下所示: enter image description here

    1 回复  |  直到 6 年前
        1
  •  2
  •   dfsq    6 年前

    因为你在打电话 mediumZoom 页面加载。你可能想要:

    Vue.prototype.$mediumZoom = mediumZoom
    // don't call function, no () here ---^