```
<script type="text/html" template
lay-url="{{ layui.setter.apiUrl.SlopsApi }}/Execute?path=government%2FBasicInfo.txt&bidID={{ layui.data(layui.setter.tableName).bidID}}"
lay-done="setTimeout(function(){layui.data.done(d)},200);">
...(这里写DIV)
</script>
<script>
layui.use(['admin', 'form', 'table', 'laytpl', 'laydate'], function () {
var $ = layui.$
, view = layui.view
, admin = layui.admin
, hongbo = layui.hongbo
, element = layui.element
, laydate = layui.laydate
, laytpl = layui.laytpl
, layer = layui.layer
, table = layui.table
, form = layui.form
, tableHelper = hongbo.tableHelper;
//全局变量
var tabCtrl, tabCtrl2, globalData = {
};
layui.data.done=function(d){
globalData.Material = d.tables[0];
globalData.DN = d.tables[1];
globalData.Bury = d.tables[2];
initPage();
}
</script>
```
**解析以上script中的内容**
```
lay-url="{{ layui.setter.apiUrl.SlopsApi }}/Execute?path=government%2FBasicInfo.txt&bidID={{ layui.data(layui.setter.tableName).bidID}}"
```
lay-url后接路径;
{{ layui.setter.apiUrl.SlopsApi }}中修改'SlopsApi',这是数据库名头
%2F:在网址中表示' / '
*****
也可以如下代码:
```
先写DIV内容
再
<script>
layui.use(['admin', 'form', 'table', 'laytpl', 'laydate'], function () {
var $ = layui.$
, view = layui.view
, admin = layui.admin
, hongbo = layui.hongbo
, element = layui.element
, laydate = layui.laydate
, laytpl = layui.laytpl
, layer = layui.layer
, table = layui.table
, form = layui.form
, tableHelper = hongbo.tableHelper;
//全局变量
var tabCtrl, tabCtrl2, globalData = {
};
admin.req({
url: layui.setter.apiUrl.SlopsApi + '/Execute',
data: {
path: 'government/BasicInfo.txt' //初始加载的 SQL路径
},
done: function (res) { debugger;
globalData.Material = res.tables[0];
//获取sql中的数据
globalData.DN = res.tables[1];
globalData.Bury = res.tables[2];
initPage();
}
});
});
</script>
```