微信小程序框架weui的基础使用

13516821613 2021-07-20 03:40:30
微信小程序 小程序教程


WeUI

你在使用小程序从零开始开发的时候,一定会想小程序有没有一个UI库,类似于前端中的Bootstrap,MD,Semantic UI这样的框架UI库,如果有的话,一定是一个完美的事情。上帝总是宠着我们,这样的好事情真的有,我的答案是weui.wxss。
WeUI 是一套同微信原生视觉体验一致的基础样式库,由微信官方设计团队为微信内网页和微信小程序量身设计,令用户的使用感知更加统一。包含buttoncell、dialog、progress、toastarticle、actionsheet、icon等各式元素。
在app.wxss内或者需要的页面引入weui.wxss,代码示例如下:
/app.wxss/

@import 'weui.wxss';

  • 1.

根组件使用class="page”,代码示例如下:

<view class="page"> </view>

  • 1.

页头和主体使用class=“page__xx”(注意是两个下划线) ,代码示例如下:

<view class="page">
<view class="page__hd"></view> <!--页头-->
<!--主体-->
<view class="page__bd"></view>
</view>

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

其他组件采用weui-xx,例如class = “weui-flex”,代码示例如下:

<view id="{{item.id}}" class="weui-flex" >

  • 1.

组件的子组件样式,
例如weui-flex还有weui-flex__item信息。
注意:子组件样式后面使用的两个下划线,"__"。

实战项目框架的制作

官方WeUI框架的weui.wxss放置于根目录style目录下,菜单图片位置根目录weixin里。
在这里插入图片描述
app.json代码示例如下:

{
"pages":[
"pages/01jichuzujian/index"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#eee",
"navigationBarTitleText": "WeUI-Wxss:讲师黄菊华",
"navigationBarTextStyle":"black"
},
"tabBar":{
"list":[
{
"pagePath": "pages/01jichuzujian/index",
"text": "基础组件",
"iconPath": "weixin/b-off.png",
"selectedIconPath": "weixin/b-on.png"
},
{
"pagePath":"pages/02biaodan/index",
"text":"表单",
"iconPath":"weixin/a-off.png",
"selectedIconPath":"weixin/a-on.png"
},
{
"pagePath": "pages/03caozuofankui/index",
"text": "操作反馈",
"iconPath": "weixin/c-off.png",
"selectedIconPath": "weixin/c-on.png"
}
,
{
"pagePath": "pages/04daohang/index",
"text": "导航相关",
"iconPath": "weixin/d-off.png",
"selectedIconPath": "weixin/d-on.png"
}
,
{
"pagePath": "pages/05sousuo/index",
"text": "搜索相关",
"iconPath": "weixin/e-off.png",
"selectedIconPath": "weixin/e-on.png"
}
]
}
}

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.

app.wxss代码示例如下:

@import 'style/weui.wxss';
page{
background-color: #F8F8F8;
font-size: 16px;
font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif;
}
.page__hd {
padding: 10px;
}
.page__bd {
padding-bottom: 40px;
}
.page__bd_spacing {
padding-left: 15px;
padding-right: 15px;
}
.page__ft{
padding-bottom: 10px;
text-align: center;
}
.page__title {
text-align: left;
font-size: 20px;
font-weight: 400;
}
.page__desc {
margin-top: 5px;
color: #888888;
text-align: left;
font-size: 14px;
}

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.

栏目首页

在这里插入图片描述
.wxml文件代码示例如下:

<view class="weui-cells weui-cells_show ">
<navigator url="/pages/01jichuzujian/01-article" class="weui-cell weui-cell_access">
<view class="weui-cell__bd">article文章</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</navigator>
<navigator url="/pages/01jichuzujian/02-badge" class="weui-cell weui-cell_access">
<view class="weui-cell__bd">Badge徽章</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</navigator>
<navigator url="/pages/01jichuzujian/03-flex" class="weui-cell weui-cell_access">
<view class="weui-cell__bd">Flex的布局和样式</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</navigator>
<navigator url="/pages/01jichuzujian/04-grid" class="weui-cell weui-cell_access">
<view class="weui-cell__bd">Grid九宫格</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</navigator>
<navigator url="/pages/01jichuzujian/05-icon" class="weui-cell weui-cell_access">
<view class="weui-cell__bd">Icon图标</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</navigator>
<navigator url="/pages/01jichuzujian/06-loadmore" class="weui-cell weui-cell_access">
<view class="weui-cell__bd">Loadmore加载更多</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</navigator>
<navigator url="/pages/01jichuzujian/07-panel" class="weui-cell weui-cell_access">
<view class="weui-cell__bd">Panel画板</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</navigator>
<navigator url="/pages/01jichuzujian/08-preview" class="weui-cell weui-cell_access">
<view class="weui-cell__bd">Preview表单预览</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</navigator>
<navigator url="/pages/01jichuzujian/09-progress" class="weui-cell weui-cell_access">
<view class="weui-cell__bd">Progress进度条</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</navigator>
<navigator url="/pages/01jichuzujian/10-footer" class="weui-cell weui-cell_access">
<view class="weui-cell__bd">Footer页脚</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</navigator>
</view>

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.

.wxss文件代码示例如下:

.weui-cells{
margin-top:0;opacity:0;
-webkit-transform:translateY(-50%);
transform:translateY(-50%);
-webkit-transition:.3s;transition:.3s
}
.weui-cells:after,.weui-cells:before{
display:none
}
.weui-cells_show{
opacity:1;
-webkit-transform:translateY(0);
transform:translateY(0)
}
.weui-cell:before{
right:15px
}

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.

article文章

在这里插入图片描述
.wxml文件代码代码如下:

<view class="page">
<view class="page__hd">
<view class="page__title">Article文章的排版布局</view>
<view class="page__desc">我是文章的描述信息,这个章节主要讲解布局要使用哪些WXSS的元素</view>
</view>
<view class="page__bd">
<view class="weui-article">
<view class="weui-article__h1">大标题</view>
<view class="weui-article__section">
<view class="weui-article__title">章标题</view>
<view class="weui-article__section">
<view class="weui-article__h3">1.1 节标题</view>
<view class="weui-article__p">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.
</view>
<view class="weui-article__p">
<image class="weui-article__img" src="/images/pic_article.png" mode="aspectFit" style="height: 180px" />
<image class="weui-article__img" src="/images/pic_article.png" mode="aspectFit" style="height: 180px" />
</view>
</view>
<view class="weui-article__section">
<view class="weui-article__h3">1.2 节标题</view>
<view class="weui-article__p">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</view>
</view>
</view>
</view>
</view>
</view>

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.

【微信小程序参考资料】

(1)微信小程序学习路线 http://www.hzyaoyi.cn/

(2)Java微信小程序商城系统指导 https://ke.qq.com/course/3066521

(3)PHP微信小程序商城系统指导 https://ke.qq.com/course/3066518

(4)微信官方文档 https://developers.weixin.qq.com/miniprogram/dev/framework/

版权声明
本文为[13516821613]所创,转载请带上原文链接,感谢
https://blog.51cto.com/u_13898481/2890823

  1. HTML + CSS + JavaScript to achieve cool Fireworks (cloud like particle text 3D opening)
  2. HTML + CSS + JavaScript realizes 520 advertising love tree (including music), which is necessary for programmers to express themselves
  3. Solve the problem of Web front-end deployment server (it can be deployed online without a server)
  4. HTML + CSS + JS make wedding countdown web page template (520 / Tanabata Valentine's Day / programmer advertisement)
  5. What else can driverless minibus do besides "Park connection"?
  6. Cloud native leads the era of all cloud development
  7. NRM mirror source management tool
  8. Bring it to you, flex Jiugong
  9. Lolstyle UI component development practice (II) -- button group component
  10. Deconstruction assignment in ES6
  11. Luo 2 peerless Tang clan was officially launched. The official gave a key point, and the broadcast time was implied
  12. 20初识前端HTML(1)
  13. 当新零售遇上 Serverless
  14. 20 initial knowledge of front-end HTML (1)
  15. When new retail meets serverless
  16. [golang] - go into go language lesson 5 type conversion
  17. [golang] - go into go language lesson 6 conditional expression
  18. HTML5(八)——SVG 之 path 详解
  19. HTML5 (8) -- detailed explanation of SVG path
  20. 需要开通VIP以后页面内容才能复制怎么办?控制台禁用javascript即可
  21. Web前端|CSS入门教程(超详细的CSS使用讲解,适合前端初学者)
  22. 实践积累 —— 用Vue3简单写一个单行横向滚动组件
  23. Serverless 全能选手,再下一城
  24. What if you need to open a VIP to copy the page content? Just disable JavaScript on the console
  25. Web front end | CSS introductory tutorial (super detailed CSS explanation, suitable for front-end beginners)
  26. Practice accumulation - write a single line horizontal scroll component simply with vue3
  27. Dili Reba is thin again. She looks elegant and high in a strapless hollow skirt, and her "palm waist" is beautiful to a new height
  28. Serverless all-round player, next city
  29. The difference between MySQL semi synchronous replication and lossless semi synchronous replication
  30. Vue表单设计器的终极解决方案
  31. The ultimate solution for Vue form designer
  32. Nginx从理论到实践超详细笔记
  33. Yu Shuxin's red backless swimsuit is split to the waist and tail, with a concave convex figure and excessive color matching, and his face is white to dazzling
  34. Nginx ultra detailed notes from theory to practice
  35. 【动画消消乐|CSS】086.炫酷水波浪Loading过渡动画
  36. typecho全站启用https
  37. CCTV has another popular employee. The off-site interpretation is very professional, and the appearance ability is no less than that of Wang Bingbing
  38. [animation Xiaole | CSS] 086. Cool water wave loading transition animation
  39. Enable HTTPS in Typecho
  40. 50天用JavaScript完成50个web项目,我学到了什么?
  41. 根据JavaScript中原生的XMLHttpRequest实现jQuery的Ajax
  42. What have I learned from completing 50 web projects with JavaScript in 50 days?
  43. "My neighbor doesn't grow up" has hit the whole network. There are countless horse music circles, and actor Zhou Xiaochuan has successfully made a circle
  44. 根据JavaScript中原生的XMLHttpRequest实现jQuery的Ajax
  45. Implement the Ajax of jQuery according to the native XMLHttpRequest in JavaScript
  46. Implement the Ajax of jQuery according to the native XMLHttpRequest in JavaScript
  47. 30 + women still wear less T-shirts and jeans. If they wear them like stars, they will lose weight
  48. 数栈技术分享前端篇:TS,看你哪里逃~
  49. Several stack technology sharing front end: TS, see where you escape~
  50. 舍弃Kong和Nginx,Apache APISIX 在趣链科技 BaaS 平台的落地实践
  51. Abandon the landing practice of Kong and nginx, Apache apisik on the baas platform of fun chain technology
  52. 浪迹天涯king教你用elementui做复杂的表格,去处理报表数据(合并表头,合并表体行和列)
  53. 前端HTML两万字图文大总结,快来看看你会多少!【️熬夜整理&建议收藏️】
  54. Wandering around the world king teaches you to use elementui to make complex tables and process report data (merge header, merge table body rows and columns)
  55. 路由刷新数据丢失 - vuex数据读取的问题
  56. Front end HTML 20000 word graphic summary, come and see how much you can【 Stay up late to sort out & suggestions]
  57. Route refresh data loss - vuex data reading problem
  58. Systemctl系统启动Nginx服务脚本
  59. Systemctl system startup nginx service script
  60. sleepless