html调用commonjs规范的js
2024-10-20 06:39:36
a.js
define(function(require, exports, module) {
var test = function(){
console.log("hello world")
} //if using just this, Tern doesn't get it, but works with RequireJS
module.exports = test; //this works with Tern already
// return test; });
test.html
<!DOCTYPE html>
<html lang="en"> <head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head> <body>
<button onclick="test()">test</button>
<script>
function test() {
require(['./a.js'], function (sayHi) {
console.log(sayHi);
});
}
</script>
<script src="https://requirejs.org/docs/release/2.3.6/minified/require.js"></script>
</body> </html>
最新文章
- Asp.Net MVC<;七>;:Model
- 虚拟机安装LINUX网络配置注意的问题
- day03-java
- 在JSP页面显示九九乘法表
- jquery之 off()方法
- CentOS 6.6 yum 方式安装sunversion 服务器
- axure7.0 汉化包下载
- 使用 环境变量 来配置批量配置apache
- 向PE文件中添加一个Section
- 使用脚本管理IIS
- c++中经常需要访问对象中的成员的三种方式
- 重操JS旧业第一弹:Script与JS加载
- 【AngularJS】 2.0 版本发布
- Spring容器组建注解@Component和Resouces实现完全注解配置
- dotnetcore 自动迁移工具
- 使用lamdba函数对list排序
- ln 软链
- 缓存系列之二:CDN与其他层面缓存
- Comparison of Static Code Analysis Tools for Java
- Top 10 Javascript MVC 框架
热门文章
- C#工程缺少IIS组件无法打开的解决办法
- linux服务器免密钥登录
- hdu-1166 敌兵布阵---树状数组模板
- PAT (Advanced Level) Practise - 1092. To Buy or Not to Buy (20)
- CUDA &;&; GPU中dim3介绍
- java基础面试题:说说&;和&;&;的区别
- 关于多行文本 textarea 在ios 真机上padding相对安卓较大问题
- 深入浅出:了解for循环中保留i值得方法
- 32-2题:LeetCode102. Binary Tree Level Order Traversal二叉树层次遍历/分行从上到下打印二叉树
- POJ 2406 Power String