Home >WeChat Applet >Mini Program Development >Summary of Forty Must-See Tips for WeChat Mini Program Development

Summary of Forty Must-See Tips for WeChat Mini Program Development

高洛峰
高洛峰Original
2017-03-14 17:42:062210browse

This article mainly introduces to you the relevant information summarizing the forty must-see tips for developing WeChat mini programs. I believe it has certain reference value for everyone to learn or use WeChat mini programs, so it is especially recommended to everyone. Friends who need it can come and take a look.

Preface

WeChat’s “mini program” has been officially launched for a week, and related topics continue to heat up. The news of Alipay's development of "mini programs" was immediately exposed, and Internet giants were gearing up. Many netizens joked that this momentum would challenge the existing "APP empire." Well, in the face of such a hot mini program, WeX5 Mobile Development Cloud has not been idle. After searching across the entire network, we have selected a must-read article for mini program developers, covering the actual development of mini programs. 40 technical points that need attention for your reference!

Q: Why can’t objects such as window be used in scripts

A: The script logic of the page is in

JsRun in Core, JsCore is an environment without window objects, so you cannot use window in scripts, nor can you operate components in scripts

Q: Why zepto/ jquery cannot be used

A:zepto/jquery will use the

window object and document object, so it cannot be used.

Q:wx.navigateTo cannot open the page

A: An application can only open 5 pages at the same time. When 5 pages are already open, After the page,

wx.navigateTo cannot open the new page normally. Please avoid multi-level interactions, or use wx.redir<a href="http://www.php.cn/wiki/1275.html" target="_blank">ectTo</a>

##Q: Style sheets do not support cascading selectors


A:

WXSS

supports class selectors starting with .

Q: Local resources cannot be obtained through css


A:

background-image<a href="http://www.php.cn/wiki/895.html" target="_blank">: You can use the network </a>picture, or base64, or use the 565b296a3970f2fc50e58c1bb915cb79 tag

Q: How to modify the background color of the window


A: Using the page

tag selector

, you can modify the style of the top-level node

page { 
  display: block; 
  min-height: 100%; 
  background-color: red;
}

## Q: Why

upload

is unsuccessfulA: In order to improve the smoothness of the experience, the size of the compiled code package must be less than 1MB. Code packages larger than 1MB will fail to be uploaded. .


Q: HTTPS request unsuccessful


A: tls only supports version 1.2 and above


Q: Network request referer

A: Network request referer cannot be set, the format is fixed to
https://

servicewechat.com/{appid }/{version}/page-frame.html, where {appid} is the appid of the mini program, {version} is the version number of the mini program, and a version number of 0 indicates the development version.

Q: Page.data cannot be directly manipulated


A: Avoid directly assigning and modifying
Page.data

, please use

Page.setData Perform operations to synchronize data to the page for rendering. How to obtain user input <a href="http://www.php.cn/code/8209.html" target="_blank"></a> To obtain user input components, you need to use components The
Attribute

bindchange synchronizes the user's input content to the AppService.


<input id="myInput" bindchange="bindChange" /><checkbox id="myCheckbox" bindchange="bindChange" />
var inputContent = {}
 
Page({
 data: {
 inputContent: {}
 },
 bindChange: function(e) {
 inputContent[e.currentTarget.id] = e.detail.value
 }
})

Q: Does the WeChat applet support fetch or promise?

A: The promise tool currently does not support it, and the fetch client does not support it. The tool will remain unified in the next version.


Q: The currentTarget.id value in the touchmove sliding

event

does not change. A: The target / currentTarget of the touchmove / touch
end

event will always be the target / currentTarget of touchstart.


Q: The parameter transmission server of the POST method of wx.request cannot receive the bug.


A: The content-type of wx.request post defaults to '
application/

json

'<a href="http://www.php.cn/wiki/1488.html" target="_blank"></a> If the server does not use json interpretation, you can set
content-type

back to

urlencoded. <p class="jb51code"></p><pre class="brush:js;">wx.request({ .... method: &quot;POST&quot;, header: { &quot;content-type&quot;: &quot;application/x-www-form-urlencoded&quot; }, ... })</pre><p></p> <p><strong>Q:wx.upload<a href="http://www.php.cn/wiki/1313.html" target="_blank">File</a>在手机上返回http码403。<br></strong></p> <p>A:安卓的微信升级到6.5.2及其以上版本。<br></p> <p><strong>Q:小程序SVG支持吗?</strong><br></p> <p>A:image的src放远程svg可以,<code>background-image里也可以。

Q:wx.request返回statusCode两端类型不一致。

A:确实有这个问题,稍后的版本将会修复。

Q:关于组件的动态生成与销毁?

A:不支持动态生成组件,但可以用 wx:for 去渲染多个。

Q:小程序支持热更吗?

A:不支持开发者自行更替。

Q:一些接口的回调IOS和Android不一致,例如支付接口,用户取消支付后,ios只回调complete方法,android则回调fail方法,官方文档也没有任何回调说明,造成开发很困难;类似的还有图片选择接口,分享接口等等。

A:支付接口,用户取消支付后,ios只回调complete方法,android则回调fail方法,问题已记录,多谢反馈。

Q:如果icon已经在服务器上了,想用直接访问网址的方法加载图片进来这样可以吗?

A:不能。

Q:ipad不能使用小程序?

A:暂时不支持ipad打开小程序。

Q:小程序音频视频播放器问题 。1、能够只隐藏进度条跟时间吗?2、现在iOS平台上的时间显示是0:00,但是android上会显示错误码,能够通过什么设置修改吗?

A:1:下个版本会修改这里的交互,不显示进度条和时间。2:6.5.3 版本已修复此问题。

Q:拍照窗口可以加浮层吗?

A:暂时不支持。

Q:开发者工具经常报jsEngineScriptError错误,会导致页面白屏。

A:移步下载最新 0.12.130400 版本的开发工具试试

Q:开发者工具里面,SPA页面,更改title无效。

A:wx.setNavigationBarTitle可以通过 API 改变导航栏标题。

Q:请问小程序页内支持长按保存图片或分享图片吗?

A:目前没有这个功能。

Q:关于swiper中的current问题。如果在新的版本中,直接设current,会产生的效果是:无论从哪个swiper元素点击进去,都会显示swiper第一个子元素的值。

A:目前swiper在处理swiper-item动态变化的情况时有一些bug,会很快修复的。

Q:小程序能引用自己服务器上的wxss和js文件吗?

A:不能,无法执行远程代码。

Q:苹果7,提示内部错误,内存占用过多。

A:页面做的预加载,列表中有图片,图片渲染的太多了,解决办法就是不当屏展示的图片,不让它渲染。

Q:小程序体验者安卓卡在加载页面进不去,IOS可以进去。

A:这是android微信客户端旧版本的bug, 请下载最新版本的 6.5.3 客户端。

Q:请问目前微信小程序支持蓝牙吗?

A:目前不支持。

Q:分享功能真机没有效果?

A:这是android微信客户端旧版本的bug, 请下载最新版本的 6.5.3 客户端。

Q:强制使用https,开发和测试环境下怎么联调和测试?

A:「微信web开发者工具」->「项目」->「开发环境不校验请求域名及TLS版本」。

Q:wx.showToast()方法无效。

调用wx.request请求网络然后在

complete: function (res) {
 
// complete
wx.hideToast();
}

在成功方法里面如果要进行showToast的时候感觉无效,并没有弹出提示框。

A: success The callback call is before complete . If it is success showToast, the next step complete hideToast will be Flush showToast.

Q: Does the text size in the picker component support modification?

A: Modification is not supported.

Q: The size of the tabBar image is too different between Android and iOS.

A: This is a bug in the old version of the android WeChat client, please download the latest version 6.5.3 client

Q: tabbar Page returns problem. How to return to the mini program homepage when clicking the return arrow in the upper left corner of a tabbar page other than the homepage? Now it is time to quit the applet directly

A: When creating a new page, use navigateTo to create a new page, while retaining the old page. If you use redirectTo, it is in the current Jump within the page.

Q: I would like to ask how to set wx.request() to be synchronous.

A: reqeust is to initiate a network request. There is no sync interface.

Q: The latest mac version of the tool is unavailable, and a failure to obtain appservice appears when entering.

A: Select direct link network in tool settings. Or the proxy software setting tool in the system directly connects to the network.

Q: Real machine view overflow-yThe slide will be very stuck.

A: The parent layer requires <a href="http://www.php.cn/wiki/902.html" target="_blank">position</a>:relative; It will not get stuck after adding it.


The above is the detailed content of Summary of Forty Must-See Tips for WeChat Mini Program Development. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn