1.直接在app.json中添加pages,会自动按照路径生成page目录文件;

2.动态修改样式:

/**
* 页面的初始数据
*/
data: {
authorInfo: [],
article: [],
index: [],
attentionBackgroundColor: 'white',
attentionTextColor: 'black'
}, 
attentionAction: function() {
wx.showToast({
title: '关注成功',
});
// 动态设置颜色和背景
var that = this;
var bgColor = this.data.attentionBackgroundColor == 'red' ? 'white' : 'red';
var textColor = this.data.attentionTextColor == 'black' ? 'white' : 'black';
// 设置背景颜色数据
this.setData({
attentionBackgroundColor: bgColor,
attentionTextColor: textColor
});
},

设置样式处:

 <view class='follow' bindtap='attentionAction' style='background-color:{{attentionBackgroundColor}};color: {{attentionTextColor}}'>
关注
</view>

3.下拉刷新,上拉加载:

app.json设置enablePullDownRefresh:

  "window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "网易蜗牛读书",
"navigationBarTextStyle": "black",
"enablePullDownRefresh": true
},

当前页设置enablePullDownRefresh为true。

js实现下拉刷新,上拉加载:

 /**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
wx.showNavigationBarLoading() //在标题栏中显示加载 //模拟加载
setTimeout(function () {
// complete
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
}, );
}, /**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
console.log('加载更多');
var that = this;
setTimeout(() => {
wx.request({
url: 'https://www.easy-mock.com/mock/5a23a9a2ff38a436c591b6fa/getArticInfo',
success: function (res) {
console.log(res.data.data.index);
console.log(res.data.data.articleInfo);
that.setData({
isHideLoadMore: true,
authors: res.data.data.index,
id: res.data.data.articleInfo
})
wx.hideLoading();
}
})
}, );
},


微信小程序技巧记录的更多相关文章

  1. 微信小程序bug记录与解决

    微信小程序bug记录 textarea textarea在模拟器上没有padding,可是在真机上会自带padding,而且在外部改不了,并且在安卓和IOS上padding还不一样 第一张图是在开发工 ...

  2. 微信小程序开发 记录

    采坑了 微信小程序--TabBar不出现的一种原因 学习微信小程序中,遇到底部的TabBar不出现的问题.经过多番尝试,终于解决问题.在此记录问题产生的原因和对策.下面先描述错误现象,接着指出错误原因 ...

  3. 微信小程序学习记录(一)

    如何定义一个全局变量: 1,在根目录下app.js中添加 App({ globalData: { g_isPlayingMusic : false, g_currentMusicPostId :nul ...

  4. 微信小程序配置文件记录

    最近公司要求,需要研究微信方面的问题,我有幸被选中了,一周时间,研究透做出个小程序来.我就从简单的开始了,记录一下,以后忘了,好来翻阅 app.json 配置文件 配置文件上写:是由哪些页面组成,配置 ...

  5. [微信小程序]——bug记录

    记录日常开发小程序遇到的一些小问题: input 输入框(unfixed) 描述:输入框focus的时候,placeholder会往上面跳动一下 当 scroll-view 遇上 fixed 描述:给 ...

  6. 【微信小程序】记录

    学习新东西时,大体都遵循一样的道理,由总入深. 以下整理一下学习小程序的过程.虽然现在做的东西还有许多问题,比如说数据超过一定数量时循环效率低,或者是多次跳转页面后会变卡等问题.这些问题只解决了部分, ...

  7. 微信小程序开发记录

    顶栏banner代码 /**app.wxss**/ .container { height: 100%; display: flex; flex-direction: column; align-it ...

  8. 微信小程序 错误记录

    1.报错this.getUserInfo(this.setData) is not a function;at pages/index/index onShow function;at api req ...

  9. 原创:从零开始,微信小程序新手入门宝典《一》

    为了方便大家了解并入门微信小程序,我将一些可能会需要的知识,列在这里,让大家方便的从零开始学习:一:微信小程序的特点张小龙:张小龙全面阐述小程序,推荐通读此文: 小程序是一种不需要下载.安装即可使用的 ...

随机推荐

  1. LeetCode 364. Nested List Weight Sum II

    原题链接在这里:https://leetcode.com/problems/nested-list-weight-sum-ii/description/ 题目: Given a nested list ...

  2. MongoDB 常用操作命令大全

    一.数据库常用命令1.Help查看命令提示 复制代码 代码如下: helpdb.help();db.yourColl.help();db.youColl.find().help();rs.help() ...

  3. POJ 2778 DNA Sequence (矩阵快速幂 + AC自动鸡)

    题目:传送门 题意: 给你m个病毒串,只由(A.G.T.C) 组成, 问你生成一个长度为 n 的 只由 A.C.T.G 构成的,不包含病毒串的序列的方案数. 解: 对 m 个病毒串,建 AC 自动机, ...

  4. 洛谷 P1230 智力大冲浪 题解

    P1230 智力大冲浪 题目描述 小伟报名参加中央电视台的智力大冲浪节目.本次挑战赛吸引了众多参赛者,主持人为了表彰大家的勇气,先奖励每个参赛者 \(m\)元.先不要太高兴!因为这些钱还不一定都是你的 ...

  5. pycharm通过pytest运行报错:No test were found 解决

    今天写代码犯了一个不应该犯的小错误,通过记录下来便于查看 1.报错代码如下: platform win32 -- Python 3.7.3, pytest-4.0.2, py-1.8.0, plugg ...

  6. Android Studio—增删改查—登录功能

    SQLite数据库的常用操作: create table if not exists 表名(字段1 类型(长度),字段2 类型(长度),...)//       建表 drop table if ex ...

  7. 模板 - 数学 - 同余 - 扩展Euclid算法

    普通的扩展欧几里得算法,通过了洛谷的扩展欧几里得算法找乘法逆元.修复了容易溢出的bug,虽然新版本仍有可能会溢出longlong,假如参与运算的数字都是longlong,假如可以的话直接使用__int ...

  8. Zrender:实现波浪纹效果

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  9. grep awk 查看nginx日志中所有访问的ip并 去重

    111.225.78.157 - - [13/Aug/2019:16:03:08 +0800] "POST /api/login HTTP/1.1" 200 249 "h ...

  10. https://zhuanlan.zhihu.com/p/32553477

    科普:QUIC协议原理分析