main.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <modal
  3. v-model="actualValue"
  4. animateContent="translateYR"
  5. >
  6. <view class="flex modal-select-container">
  7. <view @click="cancel" class="flex-all-1"></view>
  8. <view class="modal-select-footer overflow">
  9. <template
  10. v-for="(item,index) in data"
  11. >
  12. <button :key="index" class="clear-button modal-select-item modal-select-for-item center"
  13. @click.stop="trigger(item)"
  14. :open-type="item.openType"
  15. v-if="item.type === 'button'"
  16. >
  17. {{item.label}}
  18. </button>
  19. <view v-else class="modal-select-item modal-select-for-item center"
  20. :key="index"
  21. @click.stop="trigger(item)"
  22. >{{item.label}}</view>
  23. </template>
  24. <view class="modal-select-margin"></view>
  25. <view @click="cancel" class="modal-select-item center">取消</view>
  26. </view>
  27. </view>
  28. </modal>
  29. </template>
  30. <script>
  31. import modal from '@/components/modal/main.vue';
  32. import props from './props';
  33. export default {
  34. name: "modal-select",
  35. components:{
  36. modal
  37. },
  38. data(){
  39. return {
  40. actualValue:false
  41. }
  42. },
  43. watch:{
  44. value:function () {
  45. this.setValue(this.value);
  46. }
  47. },
  48. methods:{
  49. setValue(value){
  50. if (this.actualValue !== value) {
  51. this.actualValue = value;
  52. if (this.value !== value) {
  53. this.$emit('input',value);
  54. }
  55. }
  56. },
  57. cancel(){
  58. return this.setValue(false);
  59. },
  60. trigger(item){
  61. this.$emit('trigger',item);
  62. }
  63. },
  64. props
  65. }
  66. </script>
  67. <style scoped lang="scss" src="./style.scss"></style>