文件名:common.js,内容如下
//配置内容
require.config({
paths: {
"laydate": "./laydate/laydate" //laydate请自行下载,注意好路径
},
shim: {
"laydate": {
exports: 'laydate'
}
}
});
//加载这个插件
require(['laydate'],function(laydate){
//时间选择器
laydate.render({
elem: '#start_time',
type: 'datetime'
});
});
文件名:add.html,是使用laydate.js的文件,内容如下
<html>
<script src="/statics/scripts/require.js" ></script>
<div class="form-group draggable ui-draggable">
<label class="col-sm-3 control-label">开始时间:</label>
<div class="col-sm-9">
<input type="text" id="start_time" class="form-control" name="start_time" placeholder="请选择时间">
</div>
</div>
<script language="javascript" type="text/javascript">
require(['/statics/scripts/common']);
</script>
</html>