您好,欢迎来到济南诺商官方网站!
当前位置:首页 -> 新闻中心 -> 小程序开发路上踩过的坑你遇到过吗?

小程序开发路上踩过的坑你遇到过吗?

时间:2019.07.28 来源:http://www.weidaoshang.cn

1. 翻开页面数量限制(redirectTo还是navigateTo)
1. Open page limit (redirectTo or navigateTo)
微信提供 Tab 栏的设置,能够在app.json中配置,在 App 里配置的 Tab 栏将呈现在一切的一级页面。但是它有一个问题就是第一次点击 Tab 将会翻开一个新的页面,微信对翻开页面的数量限制是五个。
Wechat provides the settings of the Tab column, which can be configured in app. json. The Tab column configured in App will be displayed on all the first-level pages. But it has a problem that the first click on Tab will open a new page. There are five restrictions on the number of pages opened by Wechat.
微信提供了几个页面跳转的方式,redirectto、navigateto,还有返回。重点说这两个,redirectto会直接在原页面上翻开新页面,navigateto会新开启一个页面。由于微信在页面数量上有限制,我们产品的层级有比拟多,招致无法直接在app.json设置 Tab 栏。所以我们把 Tab 栏单独设计出来。点击 Tab 不开启新页面。在每个初级页面都援用进去,之后二级三级的页面上不运用 Tab 切换,而是需求返回到初级页面。
Wechat offers several ways to jump pages, redirectto, navigateto, and return. Focusing on these two, redirectto will open a new page directly on the original page, and navigateto will open a new page. Due to Wechat's limited number of pages, we have more levels of products, which makes it impossible to set the Tab bar directly in app. json. So we designed the Tab column separately. Click Tab to not open the new page. Each primary page is invoked, and then the secondary and tertiary pages do not use Tab switching, but need to return to the primary page.

商河网络公司
2. 树状构造的展现
2. Demonstration of Dendritic Structures
每一个库都有一个树状的学问构造,大家请看这个例子。每个层级展现的方式是一样的,所以正常状况下,我们都会选用递归的方式来使展现。比方在这张图里,当我们判别这个节点具有子节点,就想再次调用同样办法显现。但是很遗憾,小程序里,不管是运用模板,还是运用include的方式援用文件,都没有方法做到本人调本人。
Every library has a tree-like structure of knowledge. Let's see this example. Each level presents in the same way, so under normal circumstances, we will choose recursive way to make the presentation. For example, in this figure, when we judge that the node has children, we want to call the same method again. But unfortunately, in small programs, no matter using templates or using include to invoke documents, there is no way to adjust myself.
侥幸的是我们晓得层级最深有几,这样就能够写几个同样的文件和模板,加上不同的命名来调用。假如是未知层级的树状构造,就会十分难以处置。在这里能够倡议大家将树状构造变成数组的方式,加上层级标识,在 WXML 文件中能够运用循环的方式来处置层级的显现。
Fortunately, we know how deep the hierarchy is, so we can write several identical files and templates and call them with different names. If it is a tree structure of unknown hierarchy, it will be very difficult to deal with. It is advisable to transform tree structure into array, and to use hierarchical identifiers to handle hierarchical presentation in WXML files in a circular way.
3. HTML 页面在微信小程序中展现
3. HTML page display in Wechat applet
这是一个十分难处置的问题,微信不支持 HTML 页面的展现,所以需求把一切 HTML 的标签转化成小程序内允许的标签。我们运用了一个名叫wxParse的应用,它的功用就是经过正则表达式将 HTML 页面转化成 JSON 方式,再用模板的方式展示出来。在这里面规则了各个标签的款式(WXSS)。遗憾的是它也有层级方面的问题,同样是反复写了很多完整一样的模板。
This is a very difficult problem to deal with. Wechat does not support the presentation of HTML pages, so we need to convert all HTML tags into allowed tags in small programs. We use an application called wxParse, whose function is to convert HTML pages into JSON through regular expressions, and then display them in the form of templates. There are rules for each label style (WXSS). Unfortunately, it also has hierarchical problems, as well as repeated writing of many complete and identical templates.
HTML 转 JSON 工具

商河网络公司
HTML to JSON tool
转化后的 HTML 页面
Transformed HTML pages
次第调用
Secondary call
假如 HTML 的标签层级构造超出了模板个数,那么超出局部将无法显现出来。这个应用是在微信中运转的,倡议大家把数据转化放在效劳器端来停止,将转换后的数据发给小程序。另外小程序setData()一次不能超越1024K,假如你的 JSON 格式数据超越这个限制,就会很难再拼接。
If HTML's tag hierarchy construction exceeds the number of templates, then the excess will not be visible. This application runs in micro-letters. It is advocated that we put data conversion on the server side to stop and send the converted data to small programs. In addition, the small program setData () can not exceed 1024K at a time, if your JSON format data exceeds this limit, it will be difficult to reconstitute.
4. 冒泡事情
4. Bubbles
一个组件上的事情被触发后,该事情会向父节点传送,由此惹起不用要的逻辑处置,对此,运用费冒泡事情处置。
When an event on a component is triggered, it will be transmitted to the parent node, thus causing unnecessary logical disposal, which is dealt with by using bubbles.
5. 网络恳求接口wx.request()没有携带 Cookies
5. The network request interface wx. request () does not carry Cookies

商河网络公司
假如效劳器端有经过获取 Cookies 处置的逻辑没方法和小程序分离,只能为小程序单独开发新的接口。
If the server side has access to the Cookies disposal logic and can not be separated from the widget, it can only develop a new interface for the widget alone.
本文由商河网络公司 提供技术支持,更多的详细精彩内容请点击我们的网站http://www.weidaoshang.cn,我们将会全心全意为您提供满意的服务。
This article is supported by Shanghe Network Company. For more details, please click on our website http://www.weidaoshang.cn. We will provide you with satisfactory service wholeheartedly.

商河网络公司