Skip to content

Commit

Permalink
add article 小程序
Browse files Browse the repository at this point in the history
  • Loading branch information
raoenhui committed Jul 18, 2018
1 parent b91704f commit 02cc591
Show file tree
Hide file tree
Showing 24 changed files with 852 additions and 188 deletions.
73 changes: 73 additions & 0 deletions _posts/2018-07-18-小程序.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
author: raoenhui
layout: post
title: "小程序开发中的那些坑"
date: 2018-07-18 21:00
categories : wechat
comments: true
tags:
- Wechat
- Es6
---

## 前言


最近小程序特别火,不用安装,即开即用,用完就走。省流量,省安装时间等等优势吸引了大量用户,几乎所有大厂的APP都有小程序版本。我厂也有开发,所以我也加入了开发小程序的队伍,开发中的那些注意点和各位小伙伴们分享下。


### 一.css伪类看不到

在微信开发者工具中,Styles不会显示css伪类,喜欢写::before或:first-child的小伙伴们请注意了,你的伪类在控制台是看不到的。

建议不要在公共css文件夹下写伪类,本妹子就遇到过这个坑,某小伙伴在公共css上写了按钮的after加了个边框样式,找了好久才找到这个边框写在哪。

```css
button::after {
border: 2rpx solid #000;
}
```

![after.png](https://upload-images.jianshu.io/upload_images/9902136-f4ec3d52aa3df3dc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

### 二.https

小程序的图片只支持https://...的URL,后台接口不能传//或http://,否则有些安卓机会不兼容

在微信开发者工具中,可勾选"不校验合法域名、web-view(业务域名)、TLS 版本以及 HTTPS 证书"规则即可用http,但是在实体里并没有这个选项,所以建议开发时就用https路径。

![https.png](https://upload-images.jianshu.io/upload_images/9902136-9e913b9a449c2f99.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

### 三.不要换行写,有空格不行

微信开发者工具不会对代码进行trim操作,如果代码中换行,页面也直接换行。

![wrap.png](https://upload-images.jianshu.io/upload_images/9902136-f7fbc578d51c2413.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)


### 四.部分CSS3属性不能用

如transform:rotate(180deg),不能用。

### 五.Git 状态展示
project.config.json和.git需要在同层目录,Git 状态才能显示,所以project.config.json最好放在根目录中

![git.jpg](https://upload-images.jianshu.io/upload_images/9902136-03b914e0a738ae80.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

### 六.页面跳转

wx.navigateTo 新窗口打开页面 新页面有返回按钮

wx.redirectTo 关闭当前页面,跳转到应用内的某个页面 新页面没有返回按钮

### 七.IDE更换

微信开发者工具有很多快捷键都不能用,对于很多熟悉其他IDE的前端开发者来说很不习惯。
可以隐藏编辑器或分开窗口,把微信开发者工具只当作浏览器,然后然后小伙伴们就可以用自己熟悉的IDE了。

![IDE.png](https://upload-images.jianshu.io/upload_images/9902136-52a2d9087fb98508.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

> * [https://developers.weixin.qq.com/miniprogram/dev/api](https://developers.weixin.qq.com/miniprogram/dev/api)

Happy coding .. :)
2 changes: 1 addition & 1 deletion _site/about/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ <h1>Enhui Rao</h1>

<article class="notepad-page-content">
<div>
<p>Thanks For showing intrest to check about me, i’m <strong>Enhui Rao</strong>. I cook delicias code cousins for fun. I’m a Born engineer,Tech savvy, programmer, computer lover, automobiles fan, like to play anykind of machine!, curious towards css3,html5,ruby,nodejs,reactjs,ES6.This is my personal blog. It currently has 22 posts in 13 categories which combinedly have 8475 words, which will take an average reader ( WPM) approximately <span class="time">42.375</span> minutes to read. The most recent post is <a href="https://raoenhui.github.io/typescript/2018/05/31/webbpack-ts/" title="Read more about Typescript合成Webpack中">Typescript合成Webpack中</a> which was published on <time datetime="2018-05-31T21:00:00+05:30" class="post-time">31 May 2018</time>. The last commit was on Friday, 01 Jun 2018 at 08:13 AM <a href="http://en.wikipedia.org/wiki/Coordinated_Universal_Time" title="Temps Universel Coordonné">UTC</a>.</p>
<p>Thanks For showing intrest to check about me, i’m <strong>Enhui Rao</strong>. I cook delicias code cousins for fun. I’m a Born engineer,Tech savvy, programmer, computer lover, automobiles fan, like to play anykind of machine!, curious towards css3,html5,ruby,nodejs,reactjs,ES6.This is my personal blog. It currently has 23 posts in 14 categories which combinedly have 8516 words, which will take an average reader ( WPM) approximately <span class="time">42.58</span> minutes to read. The most recent post is <a href="https://raoenhui.github.io/wechat/2018/07/18/%E5%B0%8F%E7%A8%8B%E5%BA%8F/" title="Read more about 小程序开发中的那些坑">小程序开发中的那些坑</a> which was published on <time datetime="2018-07-18T21:00:00+05:30" class="post-time">18 Jul 2018</time>. The last commit was on Wednesday, 18 Jul 2018 at 04:43 PM <a href="http://en.wikipedia.org/wiki/Coordinated_Universal_Time" title="Temps Universel Coordonné">UTC</a>.</p>

<p><strong>前端妹子一枚,我平时比较繁忙(打杂、犯花痴、偷窥帅锅是正业,副业:码农、前端),所以知识点有些可能会有问题,看不过眼(强迫症的请重视我的后面一句),欢迎小伙伴们帮忙评论修改。</strong></p>

Expand Down
16 changes: 16 additions & 0 deletions _site/categories/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ <h1>Category Index</h1>
<li><a href="#cli">Cli <span>1</span></a></li>

<li><a href="#Typescript">Typescript <span>1</span></a></li>

<li><a href="#wechat">Wechat <span>1</span></a></li>



Expand Down Expand Up @@ -392,6 +394,20 @@ <h2 id="Typescript">Typescript</h2>



</ul>

<h2 id="wechat">Wechat</h2>
<ul class="post-list">




<li><a href="https://raoenhui.github.io/wechat/2018/07/18/%E5%B0%8F%E7%A8%8B%E5%BA%8F/">小程序开发中的那些坑<span class="entry-date"><time datetime="2018-07-18T21:00:00+05:30" itemprop="datePublished">July 18, 2018</time></a></li>





</ul>
</div>
</article>
Expand Down
Loading

0 comments on commit 02cc591

Please sign in to comment.