1、申请微信小程序帐号
进入小程序注册页 根据指引填写信息和提交相应的资料,就可以拥有自己的小程序帐号。
在这个小程序管理平台,你可以管理你的小程序的权限,查看数据报表,发布小程序等操作。
登录 小程序后台 ,我们可以在菜单 “设置”-“开发设置” 看到小程序的 AppID 了 。
小程序的 AppID 相当于小程序平台的一个身份证,后续你会在很多地方要用到 AppID (注意这里要区别于服务号或订阅号的 AppID)。
有了小程序帐号之后,我们需要一个工具来开发小程序。
2、安装开发工具
前往 开发者工具下载页面 ,根据自己的操作系统下载对应的安装包进行安装,有关开发者工具更详细的介绍可以查看 《开发者工具介绍》 。
打开小程序开发者工具,用微信扫码登录开发者工具,准备开发你的第一个小程序吧!
3、你的第一个小程序
新建项目选择小程序项目,选择代码存放的硬盘路径,填入刚刚申请到的小程序的 AppID,给你的项目起一个好听的名字,最后,勾选 "创建 QuickStart 项目" (注意: 你要选择一个空的目录才会有这个选项),点击确定,你就得到了你的第一个小程序了,点击顶部菜单编译就可以在微信开发者工具中预览你的第一个小程序。
4、小程序代码构成
json
后缀的JSON
配置文件wxml
后缀的WXML
模板文件wxss
后缀的WXSS
样式文件js
后缀的JS
脚本逻辑文件
5、小程序配置 app.json
app.json
是当前小程序的全局配置,包括了小程序的所有页面路径、界面表现、网络超时时间、底部 tab 等。QuickStart 项目里边的 app.json
配置内容如下:
{
"pages":[
"pages/index/index",
"pages/logs/logs"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle":"black"
}
}
6、全局配置
小程序根目录下的 app.json
文件用来对微信小程序进行全局配置。文件内容为一个 JSON 对象,有以下属性:
属性 | 类型 | 必填 | 描述 | 最低版本 |
---|---|---|---|---|
pages | string[] | 是 | 页面路径列表 | |
window | Object | 否 | 全局的默认窗口表现 | |
tabBar | Object | 否 | 底部 tab 栏的表现 | |
networkTimeout | Object | 否 | 网络超时时间 | |
debug | boolean | 否 | 是否开启 debug 模式,默认关闭 | |
functionalPages | boolean | 否 | 是否启用插件功能页,默认关闭 | 2.1.0 |
subpackages | Object[] | 否 | 分包结构配置 | 1.7.3 |
workers | string | 否 | Worker 代码放置的目录 | 1.9.90 |
requiredBackgroundModes | string[] | 否 | 需要在后台使用的能力,如「音乐播放」 | |
plugins | Object | 否 | 使用到的插件 | 1.9.6 |
preloadRule | Object | 否 | 分包预下载规则 | 2.3.0 |
resizable | boolean | 否 | iPad 小程序是否支持屏幕旋转,默认关闭 | 2.3.0 |
navigateToMiniProgramAppIdList | string[] | 否 | 需要跳转的小程序列表,详见 wx.navigateToMiniProgram | 2.4.0 |
usingComponents | Object | 否 | 全局自定义组件配置 | 开发者工具 1.02.1810190 |
permission | Object | 否 | 小程序接口权限相关设置 | 微信客户端 7.0.0 |
sitemapLocation | String | 是 | 指明 sitemap.json 的位置 |
7、微信小程序开发文档
8、作业
1、骰子布局,把整个骰子布局做出来到页面上(flex布局)
2、把小程序(底部导航功能等)完成,能在手机上看或能在开发者工具调试都可以
1、
index.html
<!DOCTYPE html>
<html>
<head>
<title>骰子布局</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="index.css">
</head>
<body style="background-color: black;width: 100%;height: 100%">
<h1 style="color: white;text-align: center;">骰子布局</h1>
<div style="display: flex ;flex-wrap: wrap;padding:5px">
<div class="box1" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box2" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box3" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box4" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box5" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box6" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box7" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box8" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box9" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box10" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box11" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box12" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box13" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box14" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px" ></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px" class="box14dot2"></div>
</div>
<div class="box15" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px" ></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px" class="box15dot2"></div>
</div>
<div class="box16" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px" class="box16dot2"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px" class="box16dot3"></div>
</div>
<div class="box17" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;padding: 1px;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box18" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;padding: 1px;margin: 10px">
<div class="box18column">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box18column">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
</div>
<div class="box19" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;padding: 1px;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box20" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;padding: 1px;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box21" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;padding: 1px;margin: 10px">
<div class="box21row1">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
<div class="box21row2">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px" ></div>
</div>
<div class="box21row3">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
</div>
<div class="box22" style="background-color: white;height: 100px;width: 100px;border-radius: 10px ;padding: 1px;margin: 10px">
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
<div style="background-color: black;height: 30px;width: 30px;border-radius: 100%;margin: 1px"></div>
</div>
</div>
</body>
</html>
index.css
.box1{
display: flex;
}
.box2{
display: flex;
justify-content: center;
}
.box3{
display: flex;
justify-content: flex-end;
}
.box4{
display: flex;
align-items: center;
}
.box5{
display: flex;
justify-content: center;
align-items: center;
}
.box6{
display: flex;
justify-content: flex-end;
align-items: center;
}
.box7{
display: flex;
align-items: flex-end;
}
.box8{
display: flex;
justify-content: center;
align-items: flex-end;
}
.box9{
display: flex;
align-items: flex-end;
justify-content: flex-end;
}
.box10{
display: flex;
justify-content: space-between;
}
.box11{
display: flex;
justify-content: space-between;
flex-direction: column;
}
.box12{
display: flex;
justify-content: space-between;
flex-direction: column;
align-items: center;
}
.box13{
display: flex;
justify-content: space-between;
flex-direction: column;
align-items: flex-end;
}
.box14{
display: flex;
}
.box14dot2{
align-self: center;
}
.box15{
display: flex;
justify-content: space-between;
}
.box15dot2{
align-self: flex-end;
}
.box16{
display: flex;
}
.box16dot2{
align-self: center;
}
.box16dot3{
align-self: flex-end;
}
.box17{
display: flex;
flex-wrap: wrap;
align-content: space-between;
justify-content: flex-end;
}
.box18{
display: flex;
flex-direction: column;
justify-content: space-between;
}
.box18column{
display: flex;
justify-content: space-between;
}
.box19{
display: flex;
flex-wrap: wrap;
align-content: space-between;
}
.box20{
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-content: space-between;
}
.box21{
display: flex;
flex-wrap: wrap;
}
.box21row1{
display: flex;
flex-basis: 100%;
}
.box21row2{
display: flex;
flex-basis: 100%;
justify-content: center;
}
.box21row3{
display: flex;
flex-basis: 100%;
justify-content: space-between;
}
.box22{
display: flex;
flex-wrap: wrap;
}
2、