uniapp开发时,我们需要将数据库中获取的时间戳格式化为某种格式的日期时间形式,可以通过uniapp官方插件市场的uni-dateformat组件来解决。
Uni官方插件地址及详细使用介绍:https://ext.dcloud.net.cn/plugin? id=3279
起初,显示日期和时间是1970年,只需将数据库中的值乘以1000。
比如我们从数据库中得到的时间戳变量是:rs.addtime,可以直接在模板template中使用,不需要注册,代码如下:
!-从数据库中获取的时间戳变量为:RS . addtime-uni-date format : date=' RS . addtime * 1000 ' format=' yyyy/mm/DD '/uni-date format。
Uni获取当前页面传递的参数和route方法let routes=getCurrentPages();//获取当前打开的页面路由数组
curroute=routes.route//Get当前页面路径//pages/webview/webview
let curParam=routes.options//获取路由参数//{'userid' 3360' 100007'}
让prevRoute=routes.route //获取上一页route //pages/index/index
//拼接参数
设param=' '
for (let key in curParam) {
param='' key '=' curParam
}
注意:prevRoute上一页获取的路径是:pages/index/index。如果要跳转到这个页面,必须在前面加一个'/',即:/pages/index/index。