| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <template>
- <transition name="actionsheet-float">
- <div v-show="currentValue" class="mint-actionsheet">
- <ul class="mint-actionsheet-list" :style="{ 'margin-bottom': cancelText ? '5px' : '0' }">
- <li v-for="( item, index ) in actions" class="mint-actionsheet-listitem" @click.stop="itemClick(item, index)">{{ item.name }}</li>
- </ul>
- <a class="mint-actionsheet-button" @click.stop="currentValue = false" v-if="cancelText">{{ cancelText }}</a>
- </div>
- </transition>
- </template>
- <style>
- @component-namespace mint {
- @component actionsheet {
- position: fixed;
- background: #e0e0e0;
- width: 100%;
- text-align: center;
- bottom: 0;
- left: 50%;
- transform: translate3d(-50%, 0, 0);
- backface-visibility: hidden;
- transition: transform .3s ease-out;
- @descendent list {
- list-style: none;
- padding: 0;
- margin: 0;
- }
- @descendent listitem {
- border-bottom: solid 1px #e0e0e0;
- }
- @descendent listitem, button {
- display: block;
- width: 100%;
- height: 45px;
- line-height: 45px;
- font-size: 18px;
- color: #333;
- background-color: #fff;
- &:active {
- background-color: #f0f0f0;
- }
- }
- }
- }
- .actionsheet-float-enter,
- .actionsheet-float-leave-active {
- transform: translate3d(-50%, 100%, 0);
- }
- </style>
- <script type="text/babel">
- import Popup from 'mint-ui/src/utils/popup';
- import 'mint-ui/src/style/popup.css';
- export default {
- name: 'mt-actionsheet',
- mixins: [Popup],
- props: {
- modal: {
- default: true
- },
- modalFade: {
- default: false
- },
- lockScroll: {
- default: false
- },
- closeOnClickModal: {
- default: true
- },
- cancelText: {
- type: String,
- default: '取消'
- },
- actions: {
- type: Array,
- default: () => []
- }
- },
- data() {
- return {
- currentValue: false
- };
- },
- watch: {
- currentValue(val) {
- this.$emit('input', val);
- },
- value(val) {
- this.currentValue = val;
- }
- },
- methods: {
- itemClick(item, index) {
- if (item.method && typeof item.method === 'function') {
- item.method(item, index);
- }
- this.currentValue = false;
- }
- },
- mounted() {
- if (this.value) {
- this.rendered = true;
- this.currentValue = true;
- this.open();
- }
- }
- };
- </script>
|