File tree Expand file tree Collapse file tree 15 files changed +162
-23
lines changed
Expand file tree Collapse file tree 15 files changed +162
-23
lines changed Original file line number Diff line number Diff line change 1- # tdesign-miniprogram-starter
1+ # Miniprogram Starter
22基于 TDesign 小程序组件库的基础模板
33
44## 初始化
77npm install
88```
99
10- 然后打开微信开发者工具,点击菜单栏 ”工具“ - “构建npm”,即可开启预览。
10+ 然后打开微信开发者工具,点击菜单栏 ”工具“ - “构建npm”,即可开启预览。
11+
12+ ## 特性
13+
14+ - [x] 支持 LESS (v0.0.1)
15+ - [x] 使用自定义 tabbar (v0.0.1)
16+ - [ ] 支持版本检测,并弹窗更新
17+ - [ ] 通过 GitHub Action 自动发布小程序
Original file line number Diff line number Diff line change 11// app.js
22App ( {
33 onLaunch ( ) {
4- // 展示本地存储能力
5- const logs = wx . getStorageSync ( 'logs' ) || [ ]
6- logs . unshift ( Date . now ( ) )
7- wx . setStorageSync ( 'logs' , logs )
8-
94 // 登录
105 wx . login ( {
116 success : res => {
Original file line number Diff line number Diff line change 11{
2- "pages" :[
2+ "pages" : [
33 " pages/index/index" ,
4- " pages/logs/logs"
4+ " pages/explore/index" ,
5+ " pages/my/index"
56 ],
6- "window" :{
7- "backgroundTextStyle" :" light" ,
7+ "window" : {
8+ "backgroundTextStyle" : " light" ,
89 "navigationBarBackgroundColor" : " #fff" ,
910 "navigationBarTitleText" : " Weixin" ,
10- "navigationBarTextStyle" :" black"
11+ "navigationBarTextStyle" : " black"
1112 },
1213 "tabBar" : {
1314 "custom" : true ,
1415 "color" : " #000000" ,
1516 "selectedColor" : " #000000" ,
1617 "backgroundColor" : " #000000" ,
17- "list" : [{
18- "pagePath" : " pages/index/index" ,
19- "text" : " 组件"
20- }, {
21- "pagePath" : " pages/logs/logs" ,
22- "text" : " 接口"
23- }]
18+ "list" : [
19+ {
20+ "pagePath" : " pages/index/index" ,
21+ "text" : " 首页"
22+ },
23+ {
24+ "pagePath" : " pages/explore/index" ,
25+ "text" : " 发现"
26+ },
27+ {
28+ "pagePath" : " pages/my/index" ,
29+ "text" : " 我的"
30+ }
31+ ]
2432 },
2533 "style" : " v2" ,
2634 "sitemapLocation" : " sitemap.json"
27- }
35+ }
Original file line number Diff line number Diff line change 11
22Component ( {
33 data : {
4+ value : 'index' ,
45 list : [ {
56 icon : 'home' ,
6- value : 'home ' ,
7+ value : 'index ' ,
78 label : '首页' ,
89 } , {
910 icon : 'control-platform' ,
1011 value : 'explore' ,
1112 label : '发现' ,
1213 } , {
1314 icon : 'user' ,
14- value : 'user ' ,
15+ value : 'my ' ,
1516 label : '我的'
1617 } ]
1718 } ,
19+ lifetimes : {
20+ ready ( ) {
21+ const pages = getCurrentPages ( ) ;
22+ const curPage = pages [ pages . length - 1 ] ;
23+
24+ if ( curPage ) {
25+ const nameRe = / p a g e s \/ ( \w + ) \/ i n d e x / . exec ( curPage . route ) ;
26+
27+ if ( nameRe [ 1 ] ) {
28+ this . setData ( {
29+ value : nameRe [ 1 ]
30+ } )
31+ }
32+ }
33+ }
34+ } ,
35+ methods : {
36+ handleChange ( e ) {
37+ const { value } = e . detail ;
38+
39+ // this.setData({ value });
40+ wx . switchTab ( {
41+ url : `/pages/${ value } /index` ,
42+ } )
43+ }
44+ }
1845} )
Original file line number Diff line number Diff line change 1- <t-tab-bar defaultValue="home ">
1+ <t-tab-bar value="{{value}}" bind:change="handleChange ">
22 <t-tab-bar-item wx:for="{{list}}" wx:key="index" icon="{{item.icon}}" value="{{item.value}}">
33 {{item.label}}
44 </t-tab-bar-item>
Original file line number Diff line number Diff line change 1+ // pages/explore/index.js
2+ Page ( {
3+
4+ /**
5+ * 页面的初始数据
6+ */
7+ data : {
8+
9+ } ,
10+
11+ /**
12+ * 生命周期函数--监听页面加载
13+ */
14+ onLoad ( options ) {
15+
16+ } ,
17+
18+ /**
19+ * 生命周期函数--监听页面初次渲染完成
20+ */
21+ onReady ( ) {
22+
23+ } ,
24+
25+ /**
26+ * 生命周期函数--监听页面显示
27+ */
28+ onShow ( ) {
29+
30+ } ,
31+
32+ /**
33+ * 生命周期函数--监听页面隐藏
34+ */
35+ onHide ( ) {
36+
37+ } ,
38+
39+ /**
40+ * 生命周期函数--监听页面卸载
41+ */
42+ onUnload ( ) {
43+
44+ } ,
45+
46+ /**
47+ * 页面相关事件处理函数--监听用户下拉动作
48+ */
49+ onPullDownRefresh ( ) {
50+
51+ } ,
52+
53+ /**
54+ * 页面上拉触底事件的处理函数
55+ */
56+ onReachBottom ( ) {
57+
58+ } ,
59+
60+ /**
61+ * 用户点击右上角分享
62+ */
63+ onShareAppMessage ( ) {
64+
65+ }
66+ } )
Original file line number Diff line number Diff line change 1+ {
2+ "navigationBarTitleText" : " 发现" ,
3+ "usingComponents" : {}
4+ }
Original file line number Diff line number Diff line change 1+ /* pages/explore/index.wxss */
Original file line number Diff line number Diff line change 1+ <view class="container">
2+ Explore Page
3+ </view>
Original file line number Diff line number Diff line change 11{
2+ "navigationBarTitleText" : " 首页" ,
23 "usingComponents" : {}
34}
You can’t perform that action at this time.
0 commit comments