每个 .vue 文件最多包含一个 < template> 块。 每个 .vue 文件最多包含一个 < script> 块。 一个 .vue 文件可以包含多个 < style> 标签。 导入 < script src="./script.js"> uni-app框架目前仅支持长度单位 px 和 %。 PS:uni-app 的基准宽度为 750px。 样式导入
pages.json 配置(tabbar/窗口) http://www.hcoder.net/tutorials/info_1339.html
生命周期
onLoad 监听页面加载,其参数为上个页面传递的数据,参数类型为object(用于页面传参),参考示例 onShow 监听页面显示 onReady 监听页面初次渲染完成 onHide 监听页面隐藏 onUnload 监听页面卸载 onPullDownRefresh 监听用户下拉动作 onReachBottom 页面上拉触底事件的处理函数 onShareAppMessage 用户点击右上角分享 微信小程序 onPageScroll 监听页面滚动 onTabItemTap 当前是 tab 页时,点击 tab 时触发。
数据绑定
data: {
title: 'Hello',
name : 'hcoder'
}, .....
{{title}}
列表渲染
{{index}} - {{item.name}}
data: {
students : [
{name : "张三", age : 18},
{name : "李四", age : 20}
]
},
条件渲染
这里是条件展示的内容....
show:false
hidden
这里是条件展示的内容....
class style 绑定
111
222333
444
555
666
777
事件处理、事件绑定、事件传参
web uniapp 对应表 click: 'tap', touchstart: 'touchstart', touchmove: 'touchmove', touchcancel: 'touchcancel', touchend: 'touchend', tap: 'tap', longtap: 'longtap', input: 'input', change: 'change', submit: 'submit', blur: 'blur', focus: 'focus', reset: 'reset', confirm: 'confirm', columnchange: 'columnchange', linechange: 'linechange', error: 'error', scrolltoupper: 'scrolltoupper', scrolltolower: 'scrolltolower', scroll: 'scroll' 在 input 和 textarea 中 change 事件会被转为 blur 事件。