Issue with foundation used in .vue single file components

↘锁芯ラ 提交于 2019-12-02 03:30:51

There is an issue when using vue components with foundation js components and that's why they are not showing as explained here

So I added this directive in my script tag:

Vue.directive('f-orbit', {
    bind: function (el) {
        new Foundation.Orbit($(el))
    },
    unbind: function (el) {
        $(el).foundation.destroy()
    }
})

And in my template I added v-f-orbit instead of the default data-orbit:

<div class="contemporary orbit" role="region" aria-label="Contemporary Pictures" v-f-orbit>

I hope this will assist someone who is stuck.

Phillis's answer above is absolutely correct. Just thought I would throw in another example, of a Foundation 6.4 dropdown-menu and Vue.js 2.

Create the custom directive called dropdown and add v-dropdown to the parent element and it should be working.

        <ul class="dropdown menu" v-dropdown>
          <li>
            <a href="#">Navigate Site &nbsp;<i class="fas fa-chevron-down"></i></a>
            <ul class="menu vertical">
              <li><a href="/auto"><i class="far fa-car"></i>&nbsp; Auto</a></li>
              <li><a href="/residential"><i class="far fa-home"></i>&nbsp; Residential</a></li>
              <li><a href="/commercial"><i class="far fa-building"></i>&nbsp; Commercial</a></li>
              <li><a href="/safety-security"><i class="far fa-building"></i>&nbsp; Safety &amp; Security</a></li>
              <li><a href="/specialty-solutions"><i class="far fa-gem"></i>&nbsp; Specialty Solutions</a></li>
              <li><a href="/dealers"><i class="fal fa-id-badge"></i></i>&nbsp; Dealers</a></li>
              <li><a href="/madicou"><i class="far fa-building"></i>&nbsp; Madico U</a></li>
              <li><a href="/about"><i class="far fa-building"></i>&nbsp; Company</a></li>
            </ul>
          </li>
        </ul>

Vue.directive('dropdown', {
  bind: function (el) {
    new Foundation.DropdownMenu($(el));
  }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!