5ucms论坛
标题:
7、POPASP快速入门第七课 模板文件的循环语句
[打印本页]
作者:
admin
时间:
2019-4-1 15:30
标题:
7、POPASP快速入门第七课 模板文件的循环语句
index.asp
<!--#include file="../popasp_2.0/popasp.asp"-->
<%
'项目部署时不要手工去创建home文件夹,系统会自动创建该文件夹
const APP_PATH = "./home"
'项目部署的时候使用POP_MVC.start方法,项目部署完之后使用POP_MVC.run方法
POP_MVC.run
%>
<%
Call A_("Index/index")
dim key,item
%>
<html>
<head>
<title>变量类型转化</title>
</head>
<body>
<ul>
<% for each key in V_("list") : set item = V_("list")(key) %>
<li><a href="post.asp?id=<%=item("id")%>"><%=item("title")%></a></li>
<% next %>
</ul>
</body>
复制代码
arr.asp
<!--#include file="../popasp_2.0/popasp.asp"-->
<%
'项目部署时不要手工去创建home文件夹,系统会自动创建该文件夹
const APP_PATH = "./home"
'项目部署的时候使用POP_MVC.start方法,项目部署完之后使用POP_MVC.run方法
POP_MVC.run
%>
<%
Call A_("Index/arr")
dim key,item
%>
<html>
<head>
<title>变量类型转化</title>
</head>
<body>
<ul>
<% for each item in V_("a") %>
<li><%=item%></li>
<% next %>
<hr>
<% for each key in V_("b") : item = V_("b")(key) %>
<li><span><%=key%></span>:<span><%=item%></span></li>
<% next %>
</ul>
</body>
</html>
复制代码
IndexAction.class.asp
<%
' 本类由系统自动生成,仅供测试用途
Class IndexAction
public Sub index()
dim rs
'在这里获取到的rs为Recordset对象
set rs = M_("post").db.page( "null,10" ).field("id,title").select()
'能过that.assign分配Recordset对象类型的变量时,会转化为Dictionary类型
that.assign "list",rs
var_export typename( V_("list") )
end Sub
public sub post
dim rs
'在这里获取到的rs为Recordset对象
set rs = M_("post").db.fieldRev("content").find()
that.assign "row",rs
var_export M_("post")
end sub
public sub arr
dim a,b
a = POP_MVC.Arr.Range(5,15) '定义5-15的一维数组
that.assign "a",a
var_export typename( V_("a") )
'将数组转化成Dictionary对象之后,键值为0,1,2...,也就是原数组的下标
that.assign "b",POP_MVC.Arr.toDict( a )
end sub
End Class
%>
复制代码
作者:
admin
时间:
2019-4-1 15:47
POP_MVC.Arr.toDict(xxx) 把xxx从数组对象 转换为 Dictionary类型数据
欢迎光临 5ucms论坛 (http://bbs.5ucms.com/)
Powered by Discuz! X3.2