「小程序JAVA实战」 小程序手写属于自己的第一个demo(六)
转自:https://idig8.com/2018/08/09/xiaochengxu-chuji-06/
自己尝试的写一个小demo,用到自定义样式,自定义底部导航,页面之间的跳转等小功能。
官方文档对于小程序开发来说要时刻打开https://developers.weixin.qq.com/miniprogram/dev/framework/config.html
源码:https://github.com/limingios/wxProgram.git 中的No.1
创建小程序
- 项目名称创建

- 精简下项目
>将不需要的都删除,简化成一个很简化的项目 until文件夹和logs文件夹都删除
//app.js
App({
onLaunch: function () {
}
})
//app.json
{
"pages":[
"pages/index/index"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle":"black"
}
}

- 定义文件夹+自定义页面内容
* 复制index文件夹为idig88,将文件夹内保留idig88.js 和idig88.wxml
* 精简idig88.wxml内容
* 新增的idig88.wxml添加到app.json中,并添加到第一行让起第一个启动
* console 可能会报错,先不用管,后面咱们会解决的,第一个主要先能出效果
* 了解小程序构成结构
<!--idig88.wxml-->
<view class="container">
这是第一个demo小程序
</view>
app.json
{
"pages":[
"pages/idig88/idig88",
"pages/index/index"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "第一个demo",
"navigationBarTextStyle":"black"
}
}



- 添加底部导航栏tabBar和网络超时设置
app.json
{
"pages":[
"pages/idig88/idig88",
"pages/index/index"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "第一个demoe",
"navigationBarTextStyle":"black"
},
"tabBar": {
"list": [
{
"pagePath": "pages/index/index",
"text": "首页"
},
{
"pagePath": "pages/idig88/idig88",
"text": "详情页面"
}
]
},
"networkTimeout": {
"request": 10000,
"downloadFile": 10000
},
"debug": true
}

- 修改index文件下的index.wxml和index.js了解数据绑定
- 在微信小程序,不像之前的html那种结构,这里得都是view容器的概念,要显示什么首先要通过view容器的方式。
<!--index.wxml-->
<view class="container">
<text class="user-motto">{{motto}}</text>
</view>
- 每个js都必然有Page({}) 这种结构
- data就是数据,里面有多个变量如果需要在页面显示绑定的数据{{变量名称}}
//index.js
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
}
})


- index增加样式
* 新建index.wxss文件添加样式名称
* txt-test 定义局顶部的距离,在微信小程序开发建议使用rpx,这个可以做到手机端的适配
/* pages/index/index.wxss */
.txt-test{
margin-top: 800rpx;
}
- 引用css名称为txt-test的样式放入text容器内
<!--index.wxml-->
<view class="container">
<text class="txt-test">{{motto}}</text>
</view>
注意这个txt-test 就是私有的,index.wxml就是私有的html调用私有的样式文件,也可以看到container他这个样式就是在私有文件里面没有而在最外层的app.wxss,它就去父节点最外层找,如果最外层有用,没有也不报错。

「小程序JAVA实战」 小程序手写属于自己的第一个demo(六)的更多相关文章
- 「小程序JAVA实战」小程序的flex布局(22)
转自:https://idig8.com/2018/08/09/xiaochengxu-chuji-22/ 之前已经把小程序的框架说完了,接下来说说小程序的组件,在说组件之前,先说说布局吧.源码:ht ...
- 「小程序JAVA实战」小程序的留言和评价功能(70)
转自:https://idig8.com/2018/10/28/xiaochengxujavashizhanxiaochengxudeliuyanhepingjiagongneng69/ 目前小程序这 ...
- 「小程序JAVA实战」小程序的举报功能开发(68)
转自:https://idig8.com/2018/09/25/xiaochengxujavashizhanxiaochengxudeweixinapicaidancaozuo66-2/ 通过点击举报 ...
- 「小程序JAVA实战」小程序的个人信息作品,收藏,关注(66)
转自:https://idig8.com/2018/09/24/xiaochengxujavashizhanxiaochengxudegerenxinxizuopinshoucangguanzhu65 ...
- 「小程序JAVA实战」小程序的关注功能(65)
转自:https://idig8.com/2018/09/24/xiaochengxujavashizhanxiaochengxudeguanzhugongneng64/ 在个人页面,根据发布者个人和 ...
- 「小程序JAVA实战」小程序的视频点赞功能开发(62)
转自:https://idig8.com/2018/09/24/xiaochengxujavashizhanxiaochengxudeshipindianzangongnengkaifa61/ 视频点 ...
- 「小程序JAVA实战」小程序的springboot后台拦截器(61)
转自:https://idig8.com/2018/09/24/xiaochengxujavashizhanxiaochengxudespringboothoutailanjieqi60/ 之前咱们把 ...
- 「小程序JAVA实战」小程序首页视频(49)
转自:https://idig8.com/2018/09/21/xiaochengxujavashizhanxiaochengxushouyeshipin48/ 视频显示的内容是视频的截图,用户的头像 ...
- 「小程序JAVA实战」小程序视频封面处理(48)
转自:https://idig8.com/2018/09/16/xiaochengxujavashizhanxiaochengxushipinfengmianchuli47/ 截图这块,在微信小程序工 ...
随机推荐
- Qt 组合键的实现
(转自:http://blog.csdn.net/zerokkqq/article/details/6686912) CTRL+Enter发送信息的实现 在现在的即时聊天程序中,一般都设置有快捷键来实 ...
- mvp和mvc的区别
一句话总结:你代码逻辑有没有写在View中的,有就是MVC,没有就是MVP MVP模式: View不直接与Model交互,而是通过与Presenter交互来与Model间接交互 Presenter与V ...
- Codeforces Round #394 (Div. 2) E. Dasha and Puzzle
E. Dasha and Puzzle time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...
- ios上传图片遇见了一个TimeoutError(DOM Exception 23)异常
TimeoutError(DOM Exception 23):The operation timed out 百度了下,没发现解决办法
- 在Windows下为PHP5.6安装redis扩展
Redis 安装 Window 下安装 下载地址:https://github.com/MSOpenTech/redis/releases. Redis 支持 32 位和 64 位.这个需要根据你系统 ...
- Android系统代码查询命令集合
Android系统代码查询命令集合 *#06# 显示MEID *#*#4636#*#* 显示版本,或更新相机韧体 *#*#7594#*#* 当长按关机按钮时,会出现一个切换手机部分设置及更改设定 WL ...
- OLE剪切板与拖拽
https://www.xuebuyuan.com/1074399.html https://blog.csdn.net/uda1985/article/details/6179801
- 为什么选择MpVue进行小程序的开发
前言 mpvue是一款使用Vue.js开发微信小程序的前端框架.使用此框架,开发者将得到完整的 Vue.js 开发体验,同时为H5和小程序提供了代码复用的能力.如果想将 H5 项目改造为小程序,或开发 ...
- Linux 安全rm
先将shell脚本放在某个全局路径下,如/usr/local/bin #!/bin/sh # safe rm # Don't remove the file, just move them to a ...
- php 日期时间运算比较
$sql= "select * from t_datestudy where id='4750' and agreemode='2' and school_agree !='1'" ...