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   荆棘人  阅读(238)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
历史上的今天:
2022-07-25 C#检测是否有网络连接
2019-07-25 vs看源代码
2017-07-25 数据库原理

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

统计

点击右上角即可分享
微信分享提示