如何将javascript标记文件添加到Vue

时间:2019-02-19 03:37:59

标签: vue.js vuejs2 vue-component

我是Vue的新手,但我尝试将JS脚本标签导入Vue,但无法正常工作,请帮助我,谢谢您的答复......

<template>
  <div>
    <div>
      <div class="bg">
      <div class="overlay-bg"></div>
      <div class="project-img project-6"></div>
    </div>

    <div class="overlay-swipe">
      <div class="over-1"></div>
      <div class="over-2"></div>
      <div class="over-3"></div>
      <div class="over-4"></div>
      <div class="over-5"></div>

      <div class="over-1-border"></div>
      <div class="over-2-border"></div>
      <div class="over-3-border"></div>
      <div class="over-4-border"></div>
    </div>
   </div>
</template>

<script src="assets/homepage/js/plugin.js"></script>
<script src="assets/homepage/js/fullsreen-showcase.js"></script>
<script src="assets/homepage/js/main.js"></script>

<style lang="scss">
  @import "../assets/homepage/awsome/font-awesome-5/css/fontawesome-all.min.css";
  @import "../assets/homepage/css/main.css";
</style>

1 个答案:

答案 0 :(得分:0)

好吧,您可以执行以下任一操作:

<template>
  <div>
    <!-- the template -->
  </div>
</template>

<script>
  import "assets/homepage/js/plugin.js";
  import "assets/homepage/js/fullsreen-showcase.js";
  import "assets/homepage/js/main.js";

  // Or if those files are modules
  // import Something from "assets/homepage/js/plugin.js";
  // ...

  export default {
    // ...
  }
</script>

或者:

<template>
  <div>
    <!-- the template -->
  </div>
</template>

<script src="assets/homepage/js/main.js"></script>

main.js

main.js作为入口点,导入其余的JS文件。

import "assets/homepage/js/plugin.js";
import "assets/homepage/js/fullsreen-showcase.js";

export default {
  // ...
}