刚开始学习layui的模块定义和使用,无法调用自定义模块
这是文件目录:
这是模块的js文件:
//myFirstModel.js
layui.define(function (exports) {
var defineFunc = {
objs:"objs 参数",
init: function (some) {
alert("init defineFunc" + some)
},
getData: function () {
alert("getData defineFunc")
}
};
exports('myFirstModel', defineFunc);
});
在jsp文件中调用:
//layout.jsp
<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Quick Start - Layui</title>
<link href="/css/layui.css" rel="stylesheet">
</head>
<body>
<script>
//alter(9999)
layui.config({
base: '/js/'
}).extend({
myFirstModel: 'myFirstModel'
});
layui.use(['myFirstModel'], function () {
var def = layui.myFirstModel;
var objs = def.objs;
def.init(objs);
def.getData();
});
</script>
</body>
</html>
实在找不出问题,甚至当我在script中加入alter(9999)页面也没反应,什么都没有