1.1.8 • Published 6 years ago

ugly-ui v1.1.8

Weekly downloads
164
License
-
Repository
-
Last release
6 years ago

背景介绍

ugly 据 Google 翻译,此词意为 #@$%$%$#%$#,emmmmmmmm...,很符合这个ui。

项目介绍

总得写点什么吧

API

button

<template>
  <ugly-button>buttin</ugly-button>
</template>

Button Attributes

参数说明类型可选值默认值
type类型Stringprimary / success / warning / danger / info / text
size尺寸Stringmedium / small / mini
round是否圆角按钮Booleanfalse
disabled是否禁用状态Booleanfalse
nativeType原生 type 属性Stringbutton / submit / resetbutton

checkbox

<template>
  <ugly-checkbox v-model="checkbox">checkbox</ugly-checkbox>
  <ugly-checkbox @input="getValue" true-label="1" false-label="2">true-label & false-label</ugly-checkbox>
</template>
<script>
export default {
  data () {
    return {
      checkbox: true
    }
  },
  methods: {
    getValue (value) {
      // value输出1或2
    }
  }
}
</script>

Checkbox Attributes

参数说明类型可选值默认值
value / v-model绑定值string / number / boolean
true-label选中时的值String / number
false-label没有选中时的值Boolean / numberfalse
disabled是否禁用状态Booleanfalse
name原生 name 属性String
checked当前是否勾选Booleanfalse

radio

<template>
  <ugly-radio v-model="radio" label="2">radio</ugly-radio>
</template>
<script>
export default {
  data () {
    return {
      radio: '1'
    }
  }
}
</script>

Radio Attributes

参数说明类型可选值默认值
value / v-model绑定值string / number / boolean
disabled是否禁用状态Booleanfalse
name原生 name 属性String

input

<template>
  <ugly-input v-model="input1" placeholder="请输入内容" size="medium" :maxlength="5" borders radius clearable></ugly-input>
  <ugly-input v-model="textarea1" type="textarea" placeholder="请输入内容"></ugly-input>
</template>
<script>
export default {
  data () {
    return {
      input1: '这是input框',
      textarea1: '这是textarea框'
    }
  }
}
</script>

Input Attributes

参数说明类型可选值默认值
type类型stringtext\textareatext
value / v-model绑定值string / number
disabled是否禁用状态Booleanfalse
name原生 name 属性String
maxlength最大输入长度number
placeholder输入框占位符string
clearable是否可清空booleanfalse
sizetext的尺寸stringmedium / small / mini
readonly是否只读booleanfalse
form原生属性stringfalse

input-number

<template>
  <ugly-input-number v-model="input_number" :min="1" :max="10" :precision="2" :step="0.1">input-number</ugly-input-number>
</template>
<script>
export default {
  data () {
    return {
      input_number: '1'
    }
  }
}
</script>

Input-number Attributes

参数说明类型可选值默认值
value / v-model绑定值number
disabled是否禁用状态Booleanfalse
name原生 name 属性String
placeholder输入框占位符string
min允许的最小值number-infinity
max允许的最大值numberinfinity
precision数值精度number
step计数器步长number1
sizetext的尺寸stringmedium / small / mini
controls是否使用控制按钮booleantrue
controls-position控制按钮位置stringrighttrue
radius是否圆角boolean

select

<template>
  <ugly-select v-model="value" @change="selectChange" @optChange="optionChange" :datas="options" placeholder="请选择"></ugly-select>
</template>
<script>
export default {
  data () {
    return {
      options:[
        [
          {value: '2019',label: '2019年'}, {value: '2020',label: '2020年'}
        ],
        [
          {value: '1',label: '1月'},{value: '2',label: '2月'},{value: '3',label: '3月'},{value: '4',label: '4月'},{value: '5',label: '5月'},{value: '6',label: '6月'},{value: '7',label: '7月'},{value: '8',label: '8月'},{value: '9',label: '9月'},{value: '10',label: '10月'},{value: '11',label: '11月'},{value: '12',label: '12月'}
        ],
        [
          {value: '1',label: '1日'},{value: '2',label: '2日'}{value: '3',label: '3日'}{value: '4',label: '4日'}{value: '5',label: '5日'}{value: '6',label: '6日'}{value: '7',label: '7日'}{value: '7',label: '7日'}{value: '8',label: '8日'}{value: '9',label: '9日'}{value: '10',label: '10日'}{value: '11',label: '11日'}{value: '12',label: '12日'}{value: '13',label: '13日'}{value: '14',label: '14日'}{value: '15',label: '15日'}{value: '16',label: '16日'}{value: '17',label: '17日'}{value: '18',label: '19日'}{value: '20',label: '20日'}{value: '21',label: '21日'}{value: '22',label: '22日'}{value: '23',label: '23日'}{value: '24',label: '24日'}{value: '25',label: '25日'}{value: '26',label: '26日'}{value: '27',label: '27日'}{value: '28',label: '28日'}{value: '29',label: '29日'}{value: '30',label: '30日'}{value: '31',label: '31日'}
        ]
      ],
      value: ''
    }
  },
  method: {
    // 年月日联动
    optionChange (type, curIndex, preIndex) {
      let options = this.options
      const days = (y, m) => {
        return new Date(y, m, 0).getDate()
      }
      switch (type) {
        case 1:
          let dayArray1 = []
          const y1 = options[0][curIndex].value
          const m1 = 1
          for (let i = 1; i <= days(y1, m1); i++) {
            dayArray1.push({value: +i, label: i + '日'})
          }
          options[2] = dayArray1
          this.$set(options, 2, dayArray1)
          break
        case 2:
          let dayArray2 = []
          const y2 = options[0][preIndex].value
          const m2 = options[1][curIndex].value
          for (let i = 1; i <= days(y2, m2); i++) {
            dayArray2.push({value: +i, label: i + '日'})
          }
          options[2] = dayArray2
          this.$set(options, 2, dayArray2)
          break
        default: break
      }
      this.options = options
    }
  }
}
</script>

select Attributes

参数说明类型可选值默认值
value / v-model绑定值string/number
disabled是否禁用状态Booleanfalse
placeholder输入框占位符string
datas下拉选项Array=[Array={value: 'string',label: 'label'},Array,Array]right

message

<template>
  <div>
    <div @click="alertMessage">打开message</div>
    <div @click="closeMessage">关闭message</div>
  </div>
</template>
<script>
export default {
  methods: {
    alertMessage () {
      this.$message({message:'这是message', duration: 5000})
    },
    closeMessage () {
      this.$message.close()
    }
  }
}
</script>

Message options

参数说明类型可选值默认值
message信息String
duration显示时间number3000

loading

<template>
  <div>
    <div @click="alertLoading">打开Loading</div>
    <div @click="closeLoading">关闭Loading</div>
  </div>
</template>
<script>
export default {
  methods: {
    alertLoading () {
      this.$loading({duration: 5000})
    },
    closeLoading () {
      this.$loading.close()
    }
  }
}
</script>

Loading options

参数说明类型可选值默认值
duration显示时间number3000

scroll

<template>
  <div class="scroll-exp1">
    <ugly-scroll
      id="thescrollplace2"
      ref="thescrollplace2"
      @pullDownHandle="pullDownHandle2"
      @pullUpHandle="pullUpHandle2"
      :pull-down="true"
      :pull-up="true">
        <ul class="ugly-scroll-ul-y">
          <li v-for="(list, index) in lists2" :key="index">{{list}}</li>
        </ul>
      </div>
      <!-- 重写下拉过程提示 -->
      <template slot="pullDowningText">
        <span>下拉中提示语</span>
      </template>
      <!-- 重写下拉结束提示 -->
      <template slot="pullDownedText">
        <span>下拉结束示语</span>
      </template>
      <!-- 重写上拉过程提示 -->
      <template slot="pullUpingText">
        <span>上拉中提示</span>
      </template>
      <!-- 重写上拉结束提示 -->
      <template slot="pullUpedText">
        <span>上拉结束提示</span>
      </template>
    </ugly-scroll>
  </div>
</template>
<script>
export default {
  data () {
    return {
      lists2: [1,2,3,4,5,6,7,8]
    }
  },
  methods: {
    pullDownHandle2 () {
      const _this = this
      let lists2 = []
      const times = Math.round((Math.random() * 10))
      for (let i = 0; i <= times; i++) {
        lists2.push(Math.round((Math.random() * 10)))
      }
      setTimeout(() => {
        _this.lists2 = lists2
        _this.$refs.thescrollplace2.pullDownBoolean(false)
      }, 1000)
    },
    pullUpHandle2 () {
      const _this = this
      setTimeout(() => {
        _this.lists2.push(9)
        _this.$refs.thescrollplace2.pullUpBoolean(false)
      }, 1000)
    }
  }
}
</script>
<style>
.scroll-exp2{
  width: 100%;
  height: 400px;
  overflow: auto;
}
.ugly-scroll-ul-y li{
  height: 100px;
  border-bottom: 1px solid #fff;
  background-color: #efefef;
}
</style>

scroll options

参数说明类型可选值默认值
id父级idstring必填
ref滚动内容refstring必填
pull-down是否显示下拉Booleanfalse
pull-up是否显示上拉Booleanfalse
scroll-type滚动方向StringX\YY

scroll slot

参数说明类型可选值默认值
pullDowningText自定义下拉过程提示html
pullDownedText自定义下拉结束提示html
pullUpingText自定义上拉过程提示html
pullUpedText自定义上拉结束提示html

scroll Handle

参数说明类型参数
pullDownHandle下拉操作function
pullUpHandle下拉操作function
pullDownBoolean改变下拉状态functionBoolean
pullUpBoolean改变下拉状态functionBoolean

swiper

<template>
  <div>
    <ugly-swiper
      id="swiper1"
      attr-class="swiper1-height"
      ref="swiper1"
      @swiperHandle="swiperhandles"
      :loop="true"
      :auto-play="4000"
      scroll-type="X"
      :pagination="true">
      <template slot="swiperWrapper">
        <div class="ugly-swiper-wrapper">
          <div v-for="(slide, index) in slides1" :key="index" @click="swiperalert(index)" class="ugly-swiper-slide slides">{{slide}}</div>
        </div>
      </template>
    </ugly-swiper>
  </div>
</template>
<script>
export default {
  data () {
    return {
      slides1: [1,2,3,4,5]
    }
  },
  methods: {
    appendSlide () {
      this.slides.push(2,3,4)
      this.$refs.swiper1.updateWrapper()
    },
    slideToSlides1 (index) {
      this.$refs.swiper1.slideTo(index)
    }
  }
}
</script>
<style>
.swiper1-height{
  height: 200px;
}
</style>

scroll options

参数说明类型可选值默认值
id父级idstring必填
ref滚动内容refstring必填
attr-class样式名Boolean
loop是无限滚动Booleanfalse
auto-play是否自动滚动Boolean, NumberY
scroll-type轮播方向stringX/YX
pagination是否显示分页器Booleanfalse

scroll slot

参数说明类型可选值默认值
swiperWrapper轮播内容html

scroll Handle

参数说明类型参数
swiperHandle动画结束是回调函数functioni-当前的index
updateWrapper重置轮播函数function-
slideTo轮播到某索引函数functioni-索引

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.0

6 years ago