en Kooboo Logo 说明文档

Inner HTML/Text

 

把内容绑定进一个元素的Inner HTML/TEXT 中去。
 
k-content  等同于v-html, k-text = v-text,   还支持Vue的 {{}} 以及 {{{}}}绑定
 
k- 代码
<script env="server">
	var text = "hello world";
	var html = "<b>hello world</b>"
</script>
<div k-content="html">html</div>
<div k-text="text">text</div>
 
结果 
 
<div><b>hello world</b></div>
<div>hello world</div>
 
相同的结果的 v- 语法
 
<script env="server">
	var text = "hello world";
	var html = "<b>hello world</b>"
</script>
<div env="server" v-html="html">html</div>
<div env="server" v-text="text">text</div>
 
或是
 
<script env="server">
	var text = "hello world";
	var html = "<b>hello world</b>"
</script>
<div env="server">{{{html}}}</div>
<div env="server">{{text}}</div>
 
结果
 
<div>hello world_appended!</div>
<div>hello world_appended!</div>
 
Merge Function
 
<script env="server">
	var text = "hello world";
</script>
<div env="server" v-text="prefix_{text}">value</div>
<div k-content="prefix_{text}">value</div>
 
Js Function
 
代码
 
<script env="server">
	var text = "hello world";
	function appendx(input) {
	    return input + "_appended!"
	}
</script>
<div env="server" v-text="appendx(text)">value</div>
<div k-content="appendx(text)">value</div>
 
结果 
 
<div>hello world_appended!</div>
<div>hello world_appended!</div>