当前位置:网站首页>The first week of wechat applet development: page setup, page Jump and data binding
The first week of wechat applet development: page setup, page Jump and data binding
2022-06-22 05:43:00 【Amyniez】

This is the main interface , Including the list of lessons learned this week
1.app.json:
{
"pages": [
"pages/index/index",
"pages/home/home",
"pages/redirect/redirect",
"pages/bind/bind"
],
"window": {
"navigationBarBackgroundColor": "#66ffcc",
"navigationBarTextStyle": "black",
"navigationBarTitleText": " Auctions "
},
"tabBar": {
"selectedColor": "#FF0000",
"list": [
{
"pagePath": "pages/index/index",
"text": " home page ",
"iconPath": "/static/tabbar/icon_mine0.jpg",
"selectedIconPath": "/static/tabbar/icon_mine2.jpg"
},
{
"pagePath": "pages/home/home",
"text": " my ",
"iconPath": "/static/tabbar/icon_home1.jpg",
"selectedIconPath": "/static/tabbar/icon_home3.jpg"
}
]
},
"sitemapLocation": "sitemap.json"
}
2.index.wxml:
<!--index.wxml-->
<view> Example 1</view>
<view class = "menu">
<view class = "item">
<image src="/static/icon_menu1.jpg"></image>
<text> Aurora </text>
</view>
<view class = 'item'>
<image src="/static/icon_menu1.jpg"></image>
<text> Aurora </text>
</view>
<view class = 'item'>
<image src="/static/icon_menu1.jpg"></image>
<text> Aurora </text>
</view>
<view class = 'item'>
<image src="/static/icon_menu1.jpg"></image>
<text> Aurora </text>
</view>
</view>
<!-- adopt js The way to jump
This method is no longer recommended by the government -->
<view bindtap="clickMe" data-nid="1426851578" data-name="amyniez"> Point me to jump </view>
<!-- Jump directly through the tag -->
<navigator url="/pages/redirect/redirect?id=666"> Jump to a new page </navigator>
<navigator url="/pages/bind/bind?id=345845342" style="font-weight: 550;"> Jump to the user access page </navigator>
<view> Example 3</view>
<view class="auction">
<view class="item">
<view class="title"> The first scene Auction list </view>
<view class="tips">
<view class="status">2022/5/26</view>
<view class="counts">1230 Views </view>
</view>
<view class="big">
<image src="/static/jiguang.jpg"></image>
</view>
<view class="small">
<image src="/static/icon_menu1.jpg"></image>
<image src="/static/icon_menu1.jpg"></image>
<image src="/static/icon_menu1.jpg"></image>
<image src="/static/icon_menu1.jpg"></image>
</view>
</view>
</view>
3.index.wxss:
/* pages/index/index.wxss */
/* Set to menu Below image And auction Below image irrelevant */
.menu image{
width: 100rpx;
height: 100rpx;
border-radius: 50rpx;
}
.menu{
display: flex;
/* Arrange horizontally */
/* The specified spindle direction is row, From left to right */
flex-direction: row;
/* How elements are displayed horizontally :center、space-around,space-between */
/* How to display in the spindle direction */
justify-content: space-around;
/* How to show in the direction of the secondary axis */
/* align-content: center; */
}
.menu .item{
display: flex;
flex-direction: column;
align-content: flex-end;
}
.auction .item .title{
font-size: 50rpx;
font-weight: 600;
}
.auction .item .tips{
display: flex;
flex-direction: row;
justify-content: space-between;
font-size: 30rpx;
color: darkgray;
}
/* Set up div Size */
.auction .item .big{
height: 500rpx;
overflow: hidden;
}
.auction .item .big image{
width: 100%;
height: 100%;
}
.auction .item .small{
display: flex;
flex-direction: row;
justify-content: flex-start;
}
.auction .item .small image{
height: 100rpx;
width: 100rpx;
padding-right: 20rpx;/* Add margins */
}
4.bind.wxml:
It mainly involves data binding :
<!--pages/bind/bind.wxml-->
<text> Data binding </text>
<!-- use {
{
}} To bind data -->
<view> data 1:{
{
message}}</view>
<view> data 2:{
{
message}}</view>
<button bindtap="changedata"> Modifying data </button>
<view> Current user name :{
{
name}}</view>
<view>
The avatars :<image src="{
{path}}" style="height: 200rpx;width: 200rpx;"></image>
</view>
<!-- How to obtain user information One , Warning : It is no longer recommended by the authorities !!! -->
<!-- <view bindtap="getUserName"> Get current user information </view> -->
<!-- adopt button Get user information Mode two : -->
<button open-type="getUserInfo" bindgetuserinfo="getUserInfo"> Get head nickname </button>
<!-- The latest way 3、 ... and : -->
<!-- <button bindtap="getUserProfile"> Get user information </button> -->
5.bind.js:
The implementation process of data binding :
// pages/bind/bind.js
/** * Initial data of the page * Be careful !!!: * Data binding can only be written to data here * It's no use writing about other places */
data: {
message:" The first auction ",
name:"",
path:"/static/tabbar/icon_home3.jpg",
},
changedata:function(){
console.log(this.data.message);// get data
// Modifying data ( error , Only the back end has been changed )
//this.data.message = " The second auction "
// Modifying data ( The front and rear ends have been changed )
this.setData({
message:" The second auction "})
},
// How to obtain user information One :
// getUserName:function(){
// var that = this;
// //console.log('amyniez');
// // Call the interface provided by wechat , Get user information
// wx.getUserInfo({
// success:function(res){
// console.log('success',res.userInfo.nickName);
// that.setData({
// name:res.userInfo.nickName,
// path:res.userInfo.avatarUrl // User avatar acquisition
// });
// },
// fail:function(res){
// console.log('fail',res)
// }
// })
// },
// How to obtain user information Two :
// Major adjustment of wechat !!!:
// Currently in use wx.getUserInfo Interface , You need to debug the basic library to 2.10 once
// On the development tool, you need to select the debugging base library 2.16.0, To support . Otherwise, the development tool cannot call wx.getUserProfile
getUserInfo:function(){
var that = this;
wx.getUserInfo({
desc:" Getting ",
success:function(res){
console.log(' To be successful ',res);
that.setData({
name:res.userInfo.nickName,
path:res.userInfo.avatarUrl
});
},
fail:function(res){
console.log('fail',res)
}
})
},
The user jumps to the page , Get the user's information :
边栏推荐
- Redis connection error: err client send auth, but no password is set 2 solutions
- innosetup判断程序已经运行方法
- Analysis of 43 cases of MATLAB neural network: Chapter 28 Application Research of decision tree classifier - breast cancer diagnosis
- Global and Chinese digital imager market development outlook and investment competitiveness analysis report 2022-2027
- 大厂晋升学习方法四:Play 学习法
- The "decentralization" mode of independent stations has risen, sweeping the tide of cross-border enterprise transformation
- 独立站优化清单丨如何有效提升站内转化率?
- QEMU ARM interrupt system architecture
- 为什么说“ CPS联盟营销 ” 是性价比最高的推广方式?
- \[\e]0;\[email protected]\h: \w\a\]\[\033[01;32m\]\[email protected]\h\[\033[0
猜你喜欢

《MATLAB 神经网络43个案例分析》:第28章 决策树分类器的应用研究——乳腺癌诊断
![P1077 [noip2012 popularization group] flower display](/img/0d/f74a2036aa261ed327d9d74291aacc.png)
P1077 [noip2012 popularization group] flower display

微信小程序开发 第一周:页面设置、页面跳转、数据绑定

通达OA漏洞分析合集

Stockage des données (avancé)

Implementation of Nacos server source code

Independent station optimization list - how to effectively improve the conversion rate in the station?

网络、IO流、反射、多线程、异常

MinGW下载安装

Key points of Facebook account "unsealing, anti sealing and maintaining ID" have been collected!
随机推荐
Learning method 4 for promotion of big factories: play learning method
Gerrit Code Review Setup
Mobile terminal layout adaptation
tmux -- ssh terminal can be closed without impact the server process
Kubernetes - deploy application to cluster
Traveler's budget (Los Angeles Valley)
OPTEE notes
Prompt box moving with the mouse
参数序列化
Working method: 3C scheme design method
printf becomes puts
P1077 [noip2012 popularization group] flower display
Graduation season | a new start, no goodbye
open source hypervisor
微信小程序开发 第一周:页面设置、页面跳转、数据绑定
中小企业签署ERP合同时,需要留意这几点
Running yolov5 reports an error attributeerror: cant get attribute sppf on module models common
[graduation season · advanced technology Er] a graduate student's chatter
A piece of code to solve the problem of automatic disconnection of Google colab
Hide symbol of dynamic library