Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{{@@item.value}} 在{{each }}中无效 #642

Open
ZevFung opened this issue Sep 10, 2021 · 0 comments
Open

{{@@item.value}} 在{{each }}中无效 #642

ZevFung opened this issue Sep 10, 2021 · 0 comments

Comments

@ZevFung
Copy link

ZevFung commented Sep 10, 2021

<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>basic-demo</title>
<script src="../../lib/template-web.js"></script>
</head>

<body>
<div id="content"></div>
<script id="test" type="text/html">
<% if (isAdmin) { %>

<h1><%=title%></h1>
<ul>
    <% for (var i = 0; i < list.length; i ++) { %>
        <li>索引 <%= i + 1 %> :<%= list[i] %></li>
    <% } %>
</ul>

<% } %>

data: <%=$data%>

{{each list item i}}
{{@item}}
{{/each}}
</script>

<script>
var data = {
	title: '基本例子',
	isAdmin: true,
	list: ['文艺</br><p></p>', '博客', '摄影', '电影', '民谣', '旅行', '吉他']
};
var html = template('test', data);
document.getElementById('content').innerHTML = html;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant