效果图展示
悬浮按钮的标签代码
<uni-fab :pattern="pattern" :content="content" :horizontal="horizontal" :vertical="vertical"
@trigger="trigger"></uni-fab>
定义数据
pattern: {
selectedColor: '#7CA1E9',
buttonColor: "#7CA1E9"
},
horizontal: 'right',
vertical: 'bottom',
content: [{
iconPath: 'https://w.ketangpai.com/img/uploadLocally.c7111cc0.svg',
selectedIconPath: 'https://w.ketangpai.com/img/uploadLocally.c7111cc0.svg',
text: '新建个人作业',
active: false
}, {
iconPath: 'https://w.ketangpai.com/img/uploadLocally.c7111cc0.svg',
selectedIconPath: 'https://w.ketangpai.com/img/uploadLocally.c7111cc0.svg',
text: '新建小组作业',
active: false
}, {
iconPath: 'https://w.ketangpai.com/img/uploadLocally.c7111cc0.svg',
selectedIconPath: 'https://w.ketangpai.com/img/uploadLocally.c7111cc0.svg',
text: '导入已有文件',
active: false
}]
方法实现
trigger(e) {
this.content.forEach(function(item) {
item.active = false;
})
e.item.active = true;
switch (e.index) {
case 0:
console.log('用户点击确定1')
uni.navigateTo({
url:'你的路径'
})
break;
case 1:
console.log('用户点击确定2')
uni.navigateTo({
url: '你的路径'
})
break;
default:
console.log('用户点击确定3')
uni.navigateTo({
url: '你的路径'
})
break;
}