欢迎登陆济南诺商济阳分站官网!
热线电话:18615207130 / 13255311026

24小时总部电话

400-689-6678

渠道合作:

18615207130(郝经理)

13255311026(郑经理)

地址:济南市高新区新泺大街1666号齐盛广场2号楼14F

邮箱:nuoshangxinxi@163.com

传真:

扫一扫

官方小程序
官方微信号
您当前的位置:首页 - 新闻中心 > 常见问题 >

小程序开发路上踩过的坑

所属行业:建筑建材 来源:http://www.daoshangbao.cn/ 发布时间:2020-06-04 浏览次数:

访问网站立即咨询

 

打开页面数量限制(redirectTo还是navigateTo)

Limit the number of open pages (redirectto or navigateto)

微信提供tab栏的设置,可以在app.json中配置,在app里配置的tab栏将出现在所有的一级页面。但是他有一个问题就是第一次点击tab将会打开一个新的页面,微信对打开页面的数量限制是五个。

Wechat provides settings for the tab bar, which can be configured in app.json. The tab bar configured in app will appear on all the first level pages. But he has a problem that the first click on tab will open a new page. Wechat has a limit of five pages.

微信提供了几个页面跳转的方式,redirectto,navigateto,还有返回。重点说这两个,redirectto会直接在原页面上打开新页面,navigateto会新开启一个页面。由于微信在页面数量上有限制,我们产品的层级有比较多,导致我们无法直接在app.json设置tab栏。所以我们把tab栏单独设计出来。点击tab不开启新页面。在每个初级页面都引用进去,之后二级三级的页面上不使用tab切换,而是需要返回到初级页面。

Wechat provides several ways to jump pages, redirect to, navigate to, and return. In particular, redirectto will open a new page directly on the original page and navigator will open a new page. Due to the limited number of wechat pages, there are many levels of our products, so we can't directly set the tab column in app.json. So we designed the tab column separately. Click tab to not open a new page. Each primary page is referenced, and then the secondary and tertiary pages do not use tab switching, but need to return to the primary page.

树状结构的展示

Display of tree structure

每一个库都有一个树状的知识结构,大家请看这个例子。每个层级展示的方式是一样的,所以正常情况下,我们都会选用递归的方式来使展示。比如在这张图里,当我们判断这个节点拥有子节点,就想再次调用同样方法显示。但是很遗憾,小程序里,不论是使用模板,还是使用include的方式引用文件,都没有办法做到自己调自己。

Each library has a tree like knowledge structure. Please see this example. Each level is displayed in the same way, so normally, we will use recursion to display. For example, in this figure, when we judge that this node has children, we want to call the same method to display again. However, it is a pity that no matter the template or the include method is used to reference the file in the applet, there is no way to adjust yourself.

QQ截图20200511174310.png

幸运的是我们知道我们层级最深有多少,这样我就可以写几个同样的文件和模板,加上不同的命名,来调用。如果是未知层级的树状结构,就会非常难以处理。在这里可以建议大家将树状结构变成数组的形式,加上层级标识,在wxml文件中可以使用循环的方式来处理层级的显示。

Fortunately, we know how deep our hierarchy is, so that I can write several same files and templates, plus different names, to call. If it is a tree structure of unknown level, it will be very difficult to deal with. Here, we can suggest that you change the tree structure into an array form, and add the upper level identification. In the wxml file, you can use the circular way to deal with the level display.

Html页面在微信小程序中展示

HTML page displayed in wechat applet

这是一个非常难处理的问题,微信不支持html页面的展示,所以需要把所有html的标签转化成小程序内允许的标签。我们使用了一个名叫wxParse的应用,这个应用的功能就是通过正则表达式将html页面转化成json形式,再用模板的方式展现出来。在这里面规定了各个标签的样式(wxss)。遗憾的是他也有层级方面的问题,同样是重复写了很多完全一样的模板。

This is a very difficult problem. Wechat does not support the display of HTML pages, so we need to convert all HTML tags into tags allowed in the applet. We used an application called wxparse. The function of this application is to convert HTML page into JSON form through regular expression, and then display it in the form of template. It specifies the style of each label (wxss). Unfortunately, he also has the problem of hierarchy. He also wrote many identical templates repeatedly.

顺序调用。如果html的标签层级结构超出了模板个数,那么超出部分将无法显示出来。这个应用是在微信中运行的,建议大家把数据转化放在服务器端来进行,将转换后的数据发给小程序。另外小程序setData()一次不能超过1024k,如果你的json格式数据超过这个限制,就会很难再拼接。

Sequential call. If the tag hierarchy of HTML exceeds the number of templates, the excess part cannot be displayed. This application is running in wechat. We suggest that you put the data conversion on the server side and send the converted data to the applet. In addition, the applet setdata() cannot exceed 1024k at a time. If your JSON format data exceeds this limit, it will be difficult to splice.

QQ截图20200511174357.png

冒泡事件

Bubbling event

一个组件上的事件被触发后,该事件会向父节点传递,网络请求接口 wx.request() 没有携带 Cookies,如果服务器端有通过获取cookies处理的逻辑没办法和小程序结合,只能为小程序单独开发新的接口。

When an event on a component is triggered, the event will be passed to the parent node. The network request interface Wx. Request() does not carry cookies. If the server side has logic to get cookies, it can't be combined with the applet, so it can only develop a new interface for the applet.

本文来自:济阳网站建设更多的内容请点击:http://www.daoshangbao.cn我们将会为您提问的问题提供一个满意的服务,欢迎您的来电!

This article comes from: Jiyang website construction more content please click: http://www.daohangbao.cn we will provide a satisfactory service for your questions, welcome your call!

 

产品推荐:

济南诺商济阳分公司

网站首页

关于我们

在线咨询

返回顶部