vue组件中引入自定义js文件

在组件的script标签内直接引入:

import myFunction from '@/util/custom.js';

 

开始使用自定义js中的方法:

export default {
  // ... other Vue component options

  methods: {
    someMethod() {
      // Call the custom function from your custom.js
      myFunction.customFunction();
      // You can also call any other function or variable defined in custom.js
    },
  },
};

 

posted on 2023-07-25 09:46  荆棘人  阅读(131)  评论(0编辑  收藏  举报

导航