微信小程序自定义分享按钮和Swiper轮播图的展示
一. 自定义分享功能
onShareAppMessage函数
在项目中找到index文件,在index.js里面添加代码:
代码:
onShareAppMessage() {
return {
title: '弹出分享时显示的分享标题'
desc: '分享页面的内容',
path: '/page/user?id=123' // 路径,传递参数到指定页面。
}
}
Swiper轮播图效果
前言: Swiper是什么
Swiper是滑动特效插件,面向手机、平板电脑等移动终端。能实现触屏焦点图、触屏Tab切换、触屏多图切换等常用效果。是目前应用较广泛的移动端网页触摸内容滑动插件。
步骤如下:
一. 找到test.js,编写代码
Page({
data: {
imgUrls: [
'https://images.unsplash.com/photo-1551334787-21e6bd3ab135?w=640',
'https://images.unsplash.com/photo-1551214012-84f95e060dee?w=640',
'https://images.unsplash.com/photo-1551446591-142875a901a1?w=640'
],
indicatorDots: true,//是否显示面板指示点
autoplay: true,//是否自动切换
interval: 3000,// 自动切换时间间隔
duration: 500,//滑动动画时长
},
})
二.找到test.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>
三.查看效果
您的鼓励就是我最大的创作动力!
如果大家觉得这篇博客不错的话,请多多点赞支持哦!
作者: 程序猫A建仔
QQ: 651405985
博客:https://blog.csdn.net/weixin_44504146