123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <template name="sunui-grand">
- <view>
- <view v-show="isHide">
- <view class="sunui-grand-hide-bg" :style="'background-color:' + bg + ';'">
- <view class="sunui-grand-summary" :style="'-webkit-line-clamp:' + clamp + ';'">{{ content }}</view>
- <view class="sunui-grand-show-btn" :style="'top:' + (clamp - 1) + 'rem;height:' + clamp / 2 + 'rem;'" v-show="clamp >= 4">
- <view @tap.stop="show" :style="{ color: color }">
- <text :style="'border-bottom: 1upx solid ' + color + ';'">{{ expandText }}</text>
- </view>
- </view>
- </view>
- </view>
- <view v-show="!isHide">
- <view class="sunui-grand-show-bg" :style="'background-color:' + bg + ';'">
- <view>{{ content }}</view>
- <view class="sunui-grand-hide-btn" v-show="shinkText != ''">
- <view @tap.stop="hide" :style="{ color: color }">{{ shinkText == 'true' || shinkText == true ? '' : shinkText }}</view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- var _self;
- export default {
- data() {
- return {
- isHide: true
- };
- },
- name: 'sunui-grand',
- props: {
- clamp: {
- type: [Number, String],
- default: `4`
- },
- color: {
- type: String,
- default: `#1D82FE`
- },
- content: {
- type: [String, Object],
- default: ``
- },
- bg: {
- type: String,
- default: `#E6E6E6`
- },
- expandText: {
- type: String,
- default: '展开阅读全文'
- },
- shinkText: {
- type: String,
- default: '点击收起全文'
- }
- },
- created() {
- _self = this;
- },
- methods: {
- show() {
- let _this = this;
- _this.isHide = false;
- },
- hide() {
- let _this = this;
- _this.isHide = true;
- }
- }
- };
- </script>
- <style>
- .sunui-grand-hide-bg {
- background-color: #e9ecef;
- padding: 4%;
- padding-bottom: 0;
- position: relative;
- }
- .sunui-grand-show-bg {
- background-color: #e9ecef;
- padding: 4%;
- }
- .sunui-grand-summary {
- overflow: hidden;
- text-overflow: clip;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- }
- .sunui-grand-show-btn {
- width: 100%;
- position: absolute;
- left: 0;
- z-index: 0;
- text-align: center;
- background-image: linear-gradient(-180deg, rgba(233, 236, 239, 0) 0%, #fff 80%);
- padding-top: 3rem;
- }
- .sunui-grand-hide-btn {
- text-align: right;
- }
- </style>
|