These applets tips, you say you can not use a?


All tips, Ado, on the code!

Components applet to change the size of the native

Official micro letter provides some basic components, but some components do not provide properties similar size, we only need a css can be resolved to radio as an example:

These applets tips, you say you can not use a?


Applet picker component range-key does not take effect

Applet picker found in the course according to the official documents written, suggesting that the list is rendered as [Object Object], look at the documentation:

These applets tips, you say you can not use a?


If the incoming usage scenarios for the component is an array of objects, you need to set the range-key to set the display of the array which value is displayed as a list content

These applets tips, you say you can not use a?


Value is not a string according to official documents, the problem lies in the range-key type, as are used in the corresponding data {} {}, the assembly will cause the incoming, the correct use of:

These applets tips, you say you can not use a?


Use of a single quote range-key wrap or Nickname directly, without using {{}}

Small single-page application to modify the background color

Settings applet page background color, a start setting up a global background color, set in the widows of the object app.json

These applets tips, you say you can not use a?


Later in the pages of the first reaction is to use a separate json file settings,

These applets tips, you say you can not use a?


Decisively found no eggs with ah, or gray page background:

These applets tips, you say you can not use a?


Solution, disposed in a corresponding page class file wxss:

These applets tips, you say you can not use a?


These applets tips, you say you can not use a?


Routing applet parameter passing, passing object parameters

Parameter passing mode applets are carried out by stitching behind the url parameter passing, usually only need to bind the mass participation id, id will be binding for the {{item.id}}, use event.currentTarget way in which to accept the click event

These applets tips, you say you can not use a?


But when you really like parameters to be passed as an object, especially his son objects, the object may be converted prior to transmission json string

These applets tips, you say you can not use a?


" />

" />

But because of the limited length of the url, the object is too long, and found that after the stitching is incomplete URL, parses out after the lead, so when routing parameter passing objects to note that parameter passing object can not be too long .

Receive mode:

Applets separately provided in the object data specific attribute value

This problem is a newbie and veteran might encounter, because small program to respond to all the data, you must use this.setData () method, now suppose I have such a data:

These applets tips, you say you can not use a?


我执行只想为addressData的address属性赋一个值该怎么做? 也许你会这样:

These applets tips, you say you can not use a?


No,No,你不需要这样,你只需要:

These applets tips, you say you can not use a?


就这么简单,如果你没用过你一定很兴奋,不要着急我们把问题升级!假设我现在的数据变成了这样:

These applets tips, you say you can not use a?


我们现在只想把discountList数组中选中对象的click值变为1,怎么办?

These applets tips, you say you can not use a?


No,No,你会发现这样是不行的,我教你一个简单方法:

These applets tips, you say you can not use a?


但是!每次都要定义变量看起来就躁!所以还要再简单!再简单!

These applets tips, you say you can not use a?


小程序接口加密时去除昵称数据含有的reshuffle表情(例如emoji)

你有没有遇见过,你要对每个用户的微信昵称就行接口发送给后台,但是他随机的报错了…… 我的天,因为每次接口都要经过MD5加密,需要将获取的用户昵称一起加密发送到后台,开始毫无知觉拿过来直接扔进去加密,直到用后台人员的微信测试,中文验签失败,几周前已经调整过中文验签的签名算法,后来发现……

他的微信昵称里有3个“屁”……

具体是什么屁……

你打开你的输入法的emoji你会发现,里面有各种表情,其中就有一个屁…… 于是想到的方法,将特殊符号先去除,替换成指定符号,再扔进去加密,上代码:

These applets tips, you say you can not use a?


至于为什么不是去除特殊表情,一开始第一反应是去除就好了,后来想到万一还有人只用特殊表情做昵称……那存进去的就是空字符串,到时候拿出来显示为空的,视觉不好看。

小程序class中使用三元表达式

代码简单至极,和vue通用

These applets tips, you say you can not use a?


去除小程序swiper组件的滚动条

小程序自带swiper组件在滚动到时候会用滚动条出现,有时候为了页面的干净,所以……干掉它!

These applets tips, you say you can not use a?


小程序跳转写绝对路径

忘记为啥用到了,反正最后弄明白了,路径拼接以‘/’开始,你总会用到

These applets tips, you say you can not use a?


小程序多行文本溢出显示省略号

这个问题,其实问题不大,但是解决了一会,主要原因有2个:

  1. 一开始考虑使用单行超出省略号的方式来做:

These applets tips, you say you can not use a?


这是单行文本的方式,一开始想着加固定高度,后来发现设备像素问题,出现有的设备会遮住半行,突然觉得不对,应该不是这样做。

2.被设备像素问题误导,去查找是不是不同设备里行高变化了 后来查询到的多行注释文本里,使用伪类太麻烦,于是查到一种样式:

These applets tips, you say you can not use a?



这种css只适用于webkit和移动端,于是完美使用在小程序上,但是记得不能设置固定高度!!

小程序页面设置页面高度100%

放代码:

These applets tips, you say you can not use a?


关键代码是父元素设置position: fixed;height: 100%;width: 100%; 注意了里面的子元素不要再使用fixed,使用absolute基于父元素定位

These applets tips, you say you can not use a?


小程序点击事件阻止冒泡处理

These applets tips, you say you can not use a?


这个时候会出现一种情况,当我点击view时,他会跳转到指定页面,当我点击view里面的image时,他会跳转2遍指定页面,第一反应就是当年做的第一个前端项目出现的新的认知,事件冒泡。

解决方法:

These applets tips, you say you can not use a?


在小程序中事件分为冒泡事件和非冒泡事件:

冒泡事件:当一个组件上的事件被触发后,该事件会向父节点传递。 非冒泡事件:当一个组件上的事件被触发后,该事件不会向父节点传递。

其中有一行字单独说明了:

bind事件绑定不会阻止冒泡事件向上冒泡,catch事件绑定可以阻止冒泡事件向上冒泡。

小程序map组件不显示坐标,且出现了bing地图的标识

map地图组件使用:

These applets tips, you say you can not use a?


使用map的过程中出现一个问题,在onload方法中调用接口,对data中的lng和lat进行赋值,然后发现,map实际显示地图为空,没有坐标,而且下方出现了bing地图的标志,顿时懵逼,难道map组件使用的不是腾讯地图的坐标?是bing地图的坐标?不会这么丧良心吧……

后来研究发现,map组件的组件渲染是优先于接口setData的异步赋值的,导致map的渲染过程中实际上longitude和latitude值都为空,且map只渲染一次。

最后拯救的方法是使用wx:if

These applets tips, you say you can not use a?


初始化mapOn为false,接口赋值lng和lat之后将mapOn赋值true,渲染map!

小程序按钮点击css效果

The program comes with a small button click component is the effect, but once you find the custom of the class he is a square, a point that is quietly stay there, click no visual sense ...... often the most part, we have their own custom button style then wrote out a common set of applets click the button effect

These applets tips, you say you can not use a?


These applets tips, you say you can not use a?


Finally no longer so rigid ......


These applets tips, you say you can not use a?


Guess you like

Origin blog.51cto.com/14516511/2436543