You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
167 lines
3.5 KiB
167 lines
3.5 KiB
<template> |
|
<view class="example-fav"> |
|
<uni-section title="基本用法" type="line"></uni-section> |
|
<view class="example-body example-body-first"> |
|
<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 title="自定义文字" type="line"></uni-section> |
|
<view class="example-body"> |
|
<uni-fav :checked="checkList[4]" :content-text="contentText" class="favBtn" @click="favClick(4)" /> |
|
</view> |
|
<uni-section title="在自定义导航栏使用" type="line"></uni-section> |
|
<view class="example-body example-body-fullWidth"> |
|
<uni-nav-bar style="width: 100%;" :fixed="false" left-icon="arrowleft" title="标题" color="#333333" background-color="#FFFFFF"> |
|
<block slot="right"> |
|
<uni-fav :checked="checkList[5]" class="favBtn-nav" :circle="true" @click="favClick(5)" /> |
|
</block> |
|
</uni-nav-bar> |
|
</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] |
|
this.$forceUpdate() |
|
} |
|
} |
|
} |
|
</script> |
|
|
|
<style> |
|
@charset "UTF-8"; |
|
|
|
/* 头条小程序组件内不能引入字体 */ |
|
/* #ifdef MP-TOUTIAO */ |
|
@font-face { |
|
font-family: uniicons; |
|
font-weight: normal; |
|
font-style: normal; |
|
src: url("~@/static/uni.ttf") format("truetype"); |
|
} |
|
|
|
/* #endif */ |
|
/* #ifndef APP-NVUE */ |
|
page { |
|
display: flex; |
|
flex-direction: column; |
|
box-sizing: border-box; |
|
background-color: #efeff4; |
|
min-height: 100%; |
|
height: auto; |
|
} |
|
|
|
view { |
|
font-size: 14px; |
|
line-height: inherit; |
|
} |
|
|
|
.example { |
|
padding: 0 15px 15px; |
|
} |
|
|
|
.example-info { |
|
padding: 15px; |
|
color: #3b4144; |
|
background: #ffffff; |
|
} |
|
|
|
.example-body { |
|
/* #ifndef APP-NVUE */ |
|
display: flex; |
|
/* #endif */ |
|
flex-direction: row; |
|
flex-wrap: wrap; |
|
justify-content: center; |
|
padding: 0; |
|
font-size: 14px; |
|
background-color: #ffffff; |
|
} |
|
|
|
/* #endif */ |
|
.example { |
|
padding: 0 15px; |
|
} |
|
|
|
.example-info { |
|
/* #ifndef APP-NVUE */ |
|
display: block; |
|
/* #endif */ |
|
padding: 15px; |
|
color: #3b4144; |
|
background-color: #ffffff; |
|
font-size: 14px; |
|
line-height: 20px; |
|
} |
|
|
|
.example-info-text { |
|
font-size: 14px; |
|
line-height: 20px; |
|
color: #3b4144; |
|
} |
|
|
|
.example-body { |
|
flex-direction: column; |
|
padding: 15px; |
|
background-color: #ffffff; |
|
} |
|
|
|
.word-btn-white { |
|
font-size: 18px; |
|
color: #FFFFFF; |
|
} |
|
|
|
.word-btn { |
|
/* #ifndef APP-NVUE */ |
|
display: flex; |
|
/* #endif */ |
|
flex-direction: row; |
|
align-items: center; |
|
justify-content: center; |
|
border-radius: 6px; |
|
height: 48px; |
|
margin: 15px; |
|
background-color: #007AFF; |
|
} |
|
|
|
.word-btn--hover { |
|
background-color: #4ca2ff; |
|
} |
|
|
|
/* #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; |
|
} |
|
</style> |