网站首页 > 技术教程 正文
1、swiper组件自定义知识点
swiper组件的指示点默认是圆圈,想要自己设置指示点,需要获得当前索引,然后赋给当前索引不同的样式,然后在做个动画就可以了。
*关键点
用change方法,然后通过e.detail.current获得索引
***示例
<!-- 顶部滑块区域 -->
<view class="swiper">
<swiper
class="swiper"
:autoplay="true"
:interval="3000"
:duration="500"
@change="changeSwiper"
>
<swiper-item v-for="item in banner" :key="item.cover_display">
<view class="swiper-image">
<image :src="item.cover_display" />
</view>
</swiper-item>
</swiper>
<!-- 轮播指示点样式修改 -->
<view class="dots">
<view v-for="(item, index) in banner.length" :key="index">
<view
class="dot"
:class="index === swiperCurrent ? ' active' : ''"
/>
</view>
</view>
</view>
12345678910111213141516171819202122232425
// 监听滑块索引的改变
changeSwiper(e) {
this.swiperCurrent = e.detail.current
},
1234
/* 指示点样式修改 */
.dots {
position: absolute;
width: 100%;
height: 8rpx;
bottom: 36rpx;
z-index: 199;
display: flex;
flex-direction: row;
justify-content: center;
}
.dot {
width: 20rpx;
height: 8rpx;
transition: all 0.5s;
background-color: #ffffff;
margin-right: 10rpx;
}
.active {
width: 40rpx;
height: 8rpx;
background-color: #306de9;
}
1234567891011121314151617181920212223
2、修改botton边框
uniapp里面botton的边框是不能直接修改的,需要修改其after
示例
.card-button::after {
border: none;
}
123
3、uni.navigateTo失效问题
如果要跳转的路由属于tabBar中,那么不能使用uni.navigateTo,需要使用uni.switchTab。
示例
uni.switchTab({
url: '../home/index'
})
123
4、input数据双向绑定问题
在小程序中input组件中的数据不会实时反应,需要开发手动赋值更新
示例
<!--输入框部分-->
<view class="edit-traveler-input-box">
<text>{{ language === "EN" ? "姓名" : "First Name" }}</text>
<input
:placeholder="
language === 'EN' ? '在此输入姓名' : '在此输入名字,例如jia jia'
"
:value="setData.first_name"
data-model="first_name"
type="value"
placeholder-class="placeholder"
@blur="changeInput"
>
<view
:class="language === 'EN' ? 'EN-class' : 'CN-class'"
@click="changeLanguage"
>{{ language }}</view>
<image src="@/static/image/default/contacts/contacts.png" />
</view>
<view v-if="language === 'CN'" class="edit-traveler-input-box">
<text>Last Name</text>
<input
placeholder="在此输入姓氏,例如Guo"
placeholder-class="placeholder"
:value="setData.last_name"
data-model="last_name"
type="value"
@blur="changeInput"
>
</view>
<view class="edit-traveler-input-box">
<text>联系方式</text>
<input
placeholder="在此输入联系方式"
placeholder-class="placeholder"
:value="setData.telephone"
data-model="telephone"
type="value"
@blur="changeInput"
>
</view>
<view class="edit-traveler-input-box">
<text>{{ myMap[id_type] }} </text>
<input
:placeholder="
id_type === 'GovernmentId' ? '在此输入身份证' : '在此输入护照'
"
placeholder-class="placeholder"
:value="setData.id_no"
data-model="id_no"
type="value"
@blur="changeInput"
>
<image
src="@/static/image/default/contacts/transformation.png"
@click="changeID"
/>
</view>
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
data() {
return {
hideModal: false, // 模态框的状态 true-隐藏 false-显示
animationData: {}, //
val: 0,
language: 'EN',
id_type: 'GovernmentId',
myMap: this.$myMap,
uid: null,
setData: {
id_no: '',
telephone: '',
first_name: '',
last_name: ''
}
}
},
methods: {
// 同步input
changeInput(e) {
const item = e.currentTarget.dataset.model
this.setData[item] = e.detail.value
}
}
123456789101112131415161718192021222324
5、input中value 属性设置不生效的问题
当重复设置某些属性为相同的值时,不会同步到view层。
解决方法可以参考:解决方法value 属性设置不生效
或者直接在得到焦点时清空,失去焦点时赋值
6、调用一些第三接口需要写在button中并定义 open-data
示例:getUserInfo
<button open-type="getUserInfo" class="rectangle" @click="getUserInfo">
1
7、ios底部使用绝对定位,上面使用margin-bottom相间隔会有回弹问题
解决办法使用padding-bottom
8、强制更新
有时候会遇到数据更新了,但是view视图部分没有更新的情况,这时候可以使用强制刷新。
this.$forceUpdate()
猜你喜欢
- 2025-07-08 一文掌握Power BI新的文本切片器(powerbi切片器横向排列)
- 2025-07-08 VBA|过程或方法内部的直接或间接调用与相对怪异的语法格式
- 2025-07-08 VBA从0学起来-批量替换(源码)(word vba批量替换)
- 2025-07-08 c++图书管理借阅系统(基于c++的图书管理系统)
- 2025-07-08 先睹为快!VCL界面DevExpress VCL 8月即将推出一系列新功能
- 2025-07-08 EXCEL循环语句FOR NEXT 举例(数字验证)
- 2025-07-08 一文彻底搞懂windows10和11的沙盒Sandbox功能及自定义配置沙盒
- 2025-07-08 Excel常用技能分享与探讨(5-宏与VBA简介 VBA常用到的函数二)
- 2025-07-08 如何学习VBA_3.3.5:VBA代码高手之路
- 2025-07-08 App开发者必会:如何用备忘录模式玩转大数据回退?
你 发表评论:
欢迎- 07-09比斯特星人玩具系列图鉴列表(比斯特官网)
- 07-09Jenkins使用Docker插件动态构建Docker镜像的方法
- 07-09精度延迟两不误,移动端性能新SOTA,谷歌TF开源轻量级EfficientNet
- 07-09TED演讲:少抱怨外部因素、多思考如何解决问题(中英文)
- 07-09CBN丨China's growth target of 5% will be reached: PBOC quarterly report
- 07-09CBN Special丨Turning snow into gold: China's winter sports, tourism ignite consumption
- 07-09波音737着陆后起火,网友:波音你咋那么多事儿呢?
- 07-09梦工厂虚拟现实平台中的萌系企鹅会向你打招呼
- 最近发表
-
- 比斯特星人玩具系列图鉴列表(比斯特官网)
- Jenkins使用Docker插件动态构建Docker镜像的方法
- 精度延迟两不误,移动端性能新SOTA,谷歌TF开源轻量级EfficientNet
- TED演讲:少抱怨外部因素、多思考如何解决问题(中英文)
- CBN丨China's growth target of 5% will be reached: PBOC quarterly report
- CBN Special丨Turning snow into gold: China's winter sports, tourism ignite consumption
- 波音737着陆后起火,网友:波音你咋那么多事儿呢?
- 梦工厂虚拟现实平台中的萌系企鹅会向你打招呼
- 火腿大讨论一个外国火腿的苦恼丨离开电网,这电台咋供电?有啥好电源推荐?
- 1989年美国空军B-1B轰炸机无前轮迫降,命大没起火,多机位拍摄
- 标签列表
-
- sd分区 (65)
- raid5数据恢复 (81)
- 地址转换 (73)
- 手机存储卡根目录 (55)
- tcp端口 (74)
- project server (59)
- 双击ctrl (55)
- 鼠标 单击变双击 (67)
- debugview (59)
- 字符动画 (65)
- flushdns (57)
- ps复制快捷键 (57)
- 清除系统垃圾代码 (58)
- web服务器的架设 (67)
- 16进制转换 (69)
- xclient (55)
- ps源文件 (67)
- filezilla server (59)
- 句柄无效 (56)
- word页眉页脚设置 (59)
- ansys实例 (56)
- 6 1 3固件 (59)
- sqlserver2000挂起 (59)
- vm虚拟主机 (55)
- config (61)
本文暂时没有评论,来添加一个吧(●'◡'●)