Blame view

pages/extUI/fav/fav.vue 2.25 KB
4b045f7c   刘淇   江阴初始化项目
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
  <template>
  	<view class="container">
  		<uni-card is-full :is-shadow="false">
  			<text class="uni-h6">用于收藏功能,可点击切换选中、不选中的状态。</text>
  		</uni-card>
  		<uni-section title="基本用法" type="line">
  			<view class="example-body">
  				<uni-fav :checked="checkList[0]" class="favBtn" @click="favClick(0)" />
  				<uni-fav :checked="checkList[1]" :star="false" class="favBtn" @click="favClick(1)" />
  				<uni-fav :checked="checkList[2]" class="favBtn" :circle="true" bg-color="#dd524d"
  					bg-color-checked="#007aff" fg-color="#ffffff" fg-color-checked="#ffffff" @click="favClick(2)" />
  				<uni-fav :checked="checkList[3]" class="favBtn" bg-color="#f8f8f8" bg-color-checked="#eeeeee"
  					fg-color="#333333" fg-color-checked="#333333" @click="favClick(3)" />
  			</view>
  		</uni-section>
  
  		<uni-section title="自定义文字" type="line">
  			<view class="example-body">
  				<uni-fav :checked="checkList[4]" :content-text="contentText" @click="favClick(4)" />
  			</view>
  		</uni-section>
  
  		<uni-section title="在自定义导航栏使用" type="line">
  			<uni-nav-bar style="width: 100%;" :fixed="false" left-icon="arrowleft" title="标题" color="#333333"
  				background-color="#FFFFFF">
  				<template v-slot:right>
  					<uni-fav :checked="checkList[5]" :circle="true" @click="favClick(5)" />
  				</template>
  			</uni-nav-bar>
  		</uni-section>
  		<view class="example-body example-body-fullWidth">
  
  		</view>
  	</view>
  </template>
  
  <script>
  	export default {
  		components: {},
  		data() {
  			return {
  				checkList: [false, false, false, false, false, false],
  				contentText: {
  					contentDefault: '追番',
  					contentFav: '已追番'
  				}
  			}
  		},
  		methods: {
  			favClick(index) {
  				this.checkList[index] = !this.checkList[index]
  				console.log(this.checkList[index]);
  				this.$forceUpdate()
  			}
  		}
  	}
  </script>
  
  <style lang="scss">
  	.example-body {
  		display: flex;
  		padding: 10px 15px;
  	}
  
  	/* #ifdef MP-ALIPAY */
  	.uni-fav {
  		margin-left: 20rpx;
  	}
  
  	/* #endif */
  
  
  	.favBtn {
  		margin: 0 20rpx 20rpx 0;
  	}
  
  
  	.example-body-fullWidth {
  		padding: 32rpx 0;
  	}
  
  	.example-body-first {
  		/* #ifndef APP-PLUS-NVUE */
  		display: flex;
  		/* #endif */
  		flex-direction: row;
  		justify-content: flex-start;
  	}
  
  	.favBtn-nav {
  		// left:-50rpx;
  	}
  </style>