<script type="tpl" id="tpl">
    <div class="pin ks-waterfall" data-id="{{id}}">
         alert("http://farm{{farm}}.static.flickr.com/{{server}}/{{id}}_{{secret}}_m.jpg");
        <a href="#" class="image">
            <img height="{{height}}" alt="{{title}}" src="http://farm{{farm}}.static.flickr.com/{{server}}/{{id}}_{{secret}}_m.jpg" />
        </a>
        <p class="description">{{title}}</p>
    </div>
</script>
上述代码中的 {{farm}},{{server}},{{id}},{{secret}}貌似是变量?
问题一:这些是自定义变量吗?
问题二:这些变量的值从哪里而来的?
问题三:type="tpl" 是什么意思?帮忙解答一下,谢谢

解决方案 »

  1.   

    这些是模版变量,  明白点,就是 需要把一组后台数据插入到html里面, 然后这些后台数据返回实际上是json格式的。 按照常规 需要是  jsonVarName.xxx来显示对应的变量,但是模版 简化了这些操作 。直接{{xxx}} 就能拿到数据。js模版都是第三方的,本上js是没有这个功能的。