微信小程序开发实战基础一、页面跳转,底部导航栏,分享,加载图片标签,列表

1、页面跳转

wx.navigateTo({ url: "../four/four" })——可返回

wx.redirectTo({ url: "../four/four" })——不可返回

<view>

<navigator url="../four/four" hover-class="changestyle">页面跳转,可以返回</navigator>

</view>

<view>

<navigator url="../logs/logs" hover-class="changestyle" redirect>页面跳转,无法返回</navigator>

</view>

2、底部导航栏

1、添加icon图片

2、 添加tabBar到app.json文件下即可

"tabBar": {

"color": "#8c8c8c",

"selectedColor": "#f4645f",

"backgroundColor": "white",

"list": [

{

"pagePath": "pages/index/index",

"text": "首页",

"iconPath": "images/1.png",

"selectedIconPath": "images/2.png"

},

{

"pagePath": "pages/tianqi/tianqi",

"text": "天气",

"iconPath": "images/wu.png",

"selectedIconPath": "images/wulv.png"

},

{

"pagePath": "pages/wode/wode",

"text": "话题",

"iconPath": "images/wo.png",

"selectedIconPath": "images/wolv.png"

}

],

"position": "bottom"

},

3、效果:

 

3 、用户点击右上角分享

1、默认方式

onShareAppMessage: function () {

 

},

2、自定义分享

onShareAppMessage: function () {

 

return {

 

title: '自定义分享标题',

 

desc: '自定义分享描述',

 

path: '/pages/user/user'

 

}

 

},

4、加载图片标签

1、单张图片

<image class="userinfo-avatar" src="./images/tt.png" ></image>

2、轮播图

wxml代码:

<swiper indicator-dots="{{indicatorDots}}"

autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">

<block wx:for="{{imgUrls}}" wx:key="unique">

<swiper-item>

<image src="{{item}}" class="slide-image"/>

</swiper-item>

</block>

</swiper>

js脚本

data: {

 

imgUrls: [

'http://e.hiphotos.baidu.com/image/pic/item/4610b912c8fcc3cef70d70409845d688d53f20f7.jpg',

'http://f.hiphotos.baidu.com/image/pic/item/4bed2e738bd4b31c5a30865b89d6277f9f2ff8c6.jpg',

'http://g.hiphotos.baidu.com/image/pic/item/83025aafa40f4bfbb5163db50d4f78f0f6361808.jpg'

],

indicatorDots: true,

autoplay: true,

interval: 3000,

duration: 500,

},

wxss样式

.slide-image {

height: 100%;

width:95%;

margin-left: 10px;

margin-right: 10px;

}

效果:

 5、条件逻辑语句

<block wx:if="{{3>2}}">>

<text>pages/tianqi/11111.wxml</text>

</block>

<block wx:else>

<text>pages/tianqi/33.wxml</text>

</block>

6、自定义变量

https://blog.csdn.net/meixi_android/article/details/94616272

7、列表渲染

1、wxml布局

<view wx:for="{{array}}" id="{{cardTeam.id}}" class="item" >

<image class="img" src="{{item.imgsrc}}" mode="scaleToFill"></image>

<view class="number-wrapper">

<text class="name">{{item.name}}</text>

<text class="name">{{item.name}}</text>

</view>

</view>

2、wxss

.item{

width: 100%;

height: 190rpx;

position: relative;

display: flex;

margin-top: 10rpx;

border-bottom: 1px solid rgb(45, 216, 216);

}

.item .img{

width: 200rpx;

height: auto;

padding: 20rpx;

}

.item .name{

margin: 10rpx 10rpx 10rpx 10rpx;

font-size: 30rpx;

overflow: hidden;

flex: 1;

}

.item .number-wrapper{

height: 100%;

flex: 1;

display: flex;

flex-direction: column;

}

3、js实现

data: {

array: [{

message: 'foo',

"imgsrc": "../../images/wo.png",

"name": "第1代处理图形音像游戏全套",

}, {

message: 'bar',

"imgsrc": "../../images/wo.png",

"name": "第2代处理图形音像游戏全套",

} , {

message: 'bar',

"imgsrc": "../../images/wo.png",

"name": "第3代处理图形音像游戏全套",

}, {

message: 'bar',

"imgsrc": "../../images/wo.png",

"name": "第4代处理图形音像游戏全套",

}, {

message: 'bar',

"imgsrc": "../../images/wo.png",

"name": "第5代处理图形音像游戏全套",

}]

},

附:全局images与pages内images引用

"imgsrc": "../../../images/tt.png",——pages内images

"imgsrc": "../../images/wo.png",——全局images

效果:

 8、刷新列表item,添加item

列表保持原状态——添加属性wx:key

<switch wx:for="{{numberArray}}" wx:key="*this" > {{item}} </switch>

1、刷新item

changedataa: function(e){

const length = this.data.array.length

for (let i = 0; i < length; ++i) {

if(i==3){

this.data.array[3].name = 'aabbcc'

}

}

this.setData({

array: this.data.array,

time: 'sfsdfewf',

})

},

2、添加item

addToFront: function(e) {

const length = this.data.objectArray.length

this.data.objectArray = [{

id: length,

unique: 'unique_' + length

}].concat(this.data.objectArray)

this.setData({

objectArray: this.data.objectArray

})

},

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/414534.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Java面向对象---重写(Override)与重载(Overload)

一、重写(Override) 重写是子类对父类的允许访问的方法的实现过程进行重新编写, 返回值和形参都不能改变。即外壳不变&#xff0c;核心重写&#xff01; 重写的好处在于子类可以根据需要&#xff0c;定义特定于自己的行为。 也就是说子类能够根据需要实现父类的方法。 重写方法…

Java集合List、Set、Map

集合是 java 基础中非常重要的一部分&#xff0c;同样也是 Java 面试中很重要的一个知识点。所以&#xff0c;给王小整理了这篇关于集合的文章。 1、接口继承关系以及实现 集合类存放于 Java.util 包中&#xff0c;主要有 3 种&#xff1a;set、list 和 map。 Collection&…

Could not find support-media-compat.aar

implementation(name: sdk-gp-4.4.4.0, ext: aar) 升级android studio到3.3版本&#xff0c;今天checkout到历史tag上运行android项目&#xff0c;死活报错 报错如下&#xff1a; Could not find support-media-compat.aar 或者如下报错&#xff1a; ERROR: Failed to reso…

SpringBoot项目修改html后不即时编译

SpringBoot项目修改html后不即时编译 springboot templates 下的 html 修改后无法达到即时编译的效果&#xff0c;搜索资料后记录笔记。原文地址&#xff1a;https://www.cnblogs.com/jiangbei/p/8439394.html 1、pom中引入依赖 <dependency> <groupId>org.spr…

工作250:uniapp--实战--flex布局--星级评分

<template><view ><view v-for"(item,index) in 5"><view style"display: flex;padding: 24rpx 0 0 30rpx;"><text style"font-size: 30rpx;color: #333333;">001-祝菲</text><text style"margin-…

微信小程序自定义变量使用,静态变量

1、创建变量 在js文件的data里面创建与赋初始值 data: { indicatorDots: true, autoplay: true, interval: 3000, duration: 500, a:10, time: (new Date().getHours()).toString(), time2: (new Date().getMonth()1).toString(), }, 2、自定义变量赋值与引用——chan…

Java异常分类及处理

一、概念 如果某个方法不能按照正常的途径完成任务&#xff0c;就可以通过另一种路径退出方法。在这种情况下 会抛出一个封装了错误信息的对象。此时&#xff0c;这个方法会立刻退出同时不返回任何值。另外&#xff0c;调用 这个方法的其他代码也无法继续执行&#xff0c;异常…

工作252:uniapp--实战--uview---tabber

第一步 <u-tabbar v-model"current" :list"list" :current"current" :mid-button"true" change"change"></u-tabbar> 第二步 export default {data() {return {list: [{iconPath: "home",selectedI…

导出数据之CSV

平常开发中&#xff0c;常见的需求就是导出数据为Excel&#xff0c;CSV格式的表格。所以&#xff0c;在此记录一下导出CSV数据的小方法 $fileName demo.csv; $data [[id>1,name>李,age>23],[id>2,name>行,age>13] ];exportCsv($fileName,$data,false);func…

css属性基础以及wxss——居中,渐变色边框,圆角边框,横向布局,重叠div,div固定在底部,input的无边框显示下划线

text-align: center;——子item居中对齐 display: flex;——子item横向布局 -webkit-justify-content: center;——子item居中 margin: auto;——子item居中 background: #f4f4f4;——背景色&#xff08;background-color: yellowgreen;&#xff09; opacity: 0.5;——透明…

Java反射机制概念及应用场景

Java反射机制概念及应用场景 Java的反射机制相信大家在平时的业务开发过程中应该很少使用到&#xff0c;但是在一些基础框架的搭建上应用非常广泛&#xff0c;今天简单的总结学习一下。 1. 什么是反射机制&#xff1f; Java反射机制是在运行状态中&#xff0c;对于任意一个类&…

eclipse链接mycat报数据源初始化失败

程序环境&#xff1a; maven eclispe mycat 1.6 mysql5.6 程序启动的时候报数据源初始化失败&#xff0c;错误日志如下&#xff1a; 2018-03-16 17:41:23 [ERROR]-[com.alibaba.druid.pool.DruidDataSource] dataSource init error java.sql.SQLException: java.lang.Illega…

微信小程序开发实战基础二、wxml模板,动态更新内联样式

1、模板使用 1、wxml中创建模板 <template name"msgItem"> <view> <text> {{index}}: {{msg}} </text> <text> Time: {{time}} </text> </view> </template> 2、js中准备数据 data: { item: { index: 0,…

DSO windowed optimization 代码 (3)

4 Schur Complement 部分信息计算 参考《DSO windowed optimization 公式》&#xff0c;Schur Complement 部分指 Hsc&#xff08;\(H_{X\rho} H_{\rho\rho}^{-1} H_{\rho X}\)&#xff09;和 bsc&#xff08;\(H_{X\rho} H_{\rho\rho}^{-1} J_{\rho}^T r\)&#xff09;。 4.1 …

Android 支付宝登录

实现效果&#xff1a; 截取authCode的方法 int startCity info.indexOf("authCode{") "authCode{".length(); int endCity info.indexOf("}", startCity); String code info.substring(startCity, endCity);//获取市Log.i("lgqshouqau…

python打造社工脚本

0x00前言&#xff1a; 大家都知道图片是有Exif信息的。里面包含着 你的GPS信息。还有拍摄时间等等的敏感信息。 0x01准备: exifread requests 0x02思路: 读取图片的Exif信息。 如果有GPS信息就将其扔到脚本的ip定位功能 0x03代码&#xff1a; import optparse from PIL import …

颓废的三天

颓废的三天 博客断更了&#xff0c;花了3天的时间终于把第一部《大江大东》看完了。 47集&#xff0c;晚上熬到3点半&#xff0c;身体特别累&#xff0c;所以这几天就没有再写东西。 豆瓣描述&#xff1a;宋运辉&#xff08;王凯饰&#xff09;天资聪颖&#xff0c;却出身不好…