我无法在Vue Web JS中为侧边栏添加外部/自定义JS

我已经有模板,但是它只是虚拟数据,我想将此模板迁移到vue版本。但是问题出在我的自定义js上,这是我的侧边栏的一部分,必须通过此自定义js进行链接。

我曾尝试将我的自定义js包含在App.vue中,其代码如下:

 

但是那也不起作用。而且我也在index.html上尝试过它,但是也无法正常工作

<template>
  <div id="app" class="wrapper">
    <link rel="stylesheet"
        href="https://use.fontawesome.com/releases/v5.2.0/css/all.css"
        integrity="sha384-hWVjflwFxL6snzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ"
        crossorigin="anonymous">
    <Sidebar />
    <div id="content">
      <Navbar />
      <router-view/>
    </div>
    <script src="assets/js/main.js"></script>
  </div>
</template>

而且我也曾尝试过类似下面的波纹管

<template>
  <div id="app" class="wrapper">
    <link rel="stylesheet"
        href="https://use.fontawesome.com/releases/v5.2.0/css/all.css"
        integrity="sha384-hWVjflwFxL6snzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ"
        crossorigin="anonymous">
    <Sidebar />
    <div id="content">
      <Navbar />
      <router-view/>
    </div>
    <script type="text/javascript">
      $(".disabled").addClass("disabledbutton");

      $(document).ready(function () {
          $('#sidebarCollapse').on('click',function () {
              $('#sidebar').toggleclass('active');
          });
      });
    </script>
  </div>
</template>

很难通过编写来描述它,因为此代码用于使边栏具有交互性。与其他侧边栏一样,能够打开和关闭。

zqscydqyzj 回答:我无法在Vue Web JS中为侧边栏添加外部/自定义JS

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3155225.html

大家都在问