动态设置页面Title或Meta值
在编写页面过程中,我们往往需要为一个页面设置动态的元数据, 比如文章页面我们需要将
Title和Author Meta设置为文章的标题和作者.我们只需使用占位符来定义我们需要动态的内容 (如果是
Layout页面,则在页面设置中设置)<head>
	<meta charset="UTF-8">
	<title>My WebSite - {title}</title>
	<meta name="author" content="{author}">
</head>接下来在编写页面代码的过程中,动态为我们定义的变量赋值
<body>
	<div>
        <script env="server">
            k.state.set("title","food article");
            k.state.set("author","Alex");
        </script>
    </div>
</body>查看生成的html,已经变为我们设置的值
<head>
	<meta charset="UTF-8">
	<title>My WebSite - food article</title>
	<meta name="author" content="Alex">
</head>
 
 