【杂谈】Mip中列表组件怎样用
2019-11-18杂谈搜奇网43°c
A+ A-
本篇文章主要给人人引见MIP中列表组件的运用。
MIP(挪动网页加速器)中的列表组件能够衬着同步数据,或许异步要求数据后衬着。
引荐参考手册:《MIP文档手册》
下面我们经由过程组件代码示例给人人细致引见MIP中列表组件的运用。
假如我们想要在mip文件中运转列表组件,须要在mip文件body中引入以下js剧本:
<script src="https://c.mipcdn.com/static/v1/mip-list/mip-list.js"> </script> <script src="https://c.mipcdn.com/static/v1/mip-mustache/mip-mustache.js"> </script>
1、基础用法
<mip-list src="https://xxx" preLoad> <template type="mip-mustache"> <div> <li>name: {{name}}</li> <li>alias: {{alias}}</li> </div> </template></mip-list>
注:JSONP 异步要求的接口须要遵照范例 callback 为 'callback'。
2、定制模板
<mip-list template="mip-template-id" src="https://xxx" preLoad> <template type="mip-mustache" id="mip-template-id"> <div> <li>name: {{name}}</li> <li>alias: {{alias}}</li> </div> </template></mip-list>
3、同步数据
<mip-list synchronous-data> <script type="application/json"> { "items": [ { "name": "lee", "alias": "xialong" }, { "name": "ruige", "alias": "ruimm" }, { "name": "langbo", "alias": "bobo" } ] } </script> <template type="mip-mustache"> <div> <li>name: {{name}}</li> <li>alias: {{alias}}</li> </div> </template></mip-list>
4、点击加载更多
<mip-list template="mip-template-id" src="http://xxx?a=a&b=b" id="mip-list" has-more pnName="pageNum" pn=2 timeout="3000" preLoad> <template type="mip-mustache" id="mip-template-id"> <div> <li>{{key}}: {{value}}</li> </div> </template></mip-list><div class="mip-list-more" on="tap:mip-list.more"> 点击检察更多 </div>
注:有 has-more 属性时,<mip-list> 标签必需要有 id 属性,同时须要有点击按钮的 DOM 节点,而且此节点有 on 属性,属性值为:tap:对应mip-list的id.more
相干属性引见:
src:异步要求的数据接口,假如没有其他参数末端请不要带 ?
synchronous-data:运用同步数据开关属性
id:<mip-list> 组件 id
has-more:是不是有点击睁开更多功用
pnName:翻页变量名
pn:翻页初始页码,每次要求会自动加 1
preLoad:异步加载数据,假如增加 preLoad 参数,则在初始化时加载第一页内容
timeout:fetch-jsonp 要求的超时时候。
本篇文章就是关于MIP中列表组件的运用引见,愿望对须要的朋侪有所协助!那末更多的罕见的MIP组件,如轮播图组件、内联框架组件、折叠菜单组件、App推行下载组件、Mip表单组件、Mip快速回顶组件等,感兴趣的朋侪也能够参考相干文章进修!
以上就是Mip中列表组件怎样用的细致内容,更多请关注ki4网别的相干文章!