最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

基于vue2.0+vuex的日期選擇組件功能實現(xiàn)

 更新時間:2017年03月13日 14:41:03   作者:Jamie  
這篇文章主要介紹了 基于vue2.0+vuex的日期選擇組件功能實現(xiàn),詳細介紹了使用vue編寫的日期組件,,非常具有實用價值,需要的朋友可以參考下。

calendar vue日期選擇組件

一個選擇日期的vue組件

基于vue2.0 + vuex

原本是想找這樣的一個組件的,查看了vuex后,發(fā)現(xiàn)vuex的寫法還不是基于2.0的,所以就自己動手做了

demo展示&&項目中的使用

目錄結構

demo 用vue-cli 的webpack-simple構建的

calendar
 |--dist build生成的目錄
 |--doc  展示圖片
 |--src
   |--assets 資源
   |--components
     |--calendar  日期組件
     |--dateScroll 滾動的子組件
   |--css
   |store  vuex目錄
     |--modules
       |--calendar  
     |--mutation   組件的一些狀態(tài)
     |--store
   |App.vue  入口
   |main.js

組件使用

組件可以傳入一個年份的范圍,startTime 和 endTime 都是數(shù)字, 默認是1900 - 2050

觸發(fā)組件 this.$store.dispatch('calendarStatus',true)

  <template>
   <div id="app">
    <p @click = "setDate">點擊設置日期</p>
     <!--顯示返回的日期-->
    <p>{{date}}</p>
     <!--組件-->
    <com-calendar :style = "calendar" :startTime = "start" :endTime="end"></com-calendar>
      <!--遮罩-->
    <div v-show = "mark" class="mark" @touchmove.stop.prevent ="" @touchstart.stop.prevent ="" @touchend.stop.prevent =""></div>

   </div>
  </template>

  <script>
   require('./css/style.scss');
  import calendar from './components/calendar';
  export default {
   name: 'app',
   data () {
    return {
     //選擇日期的開始返回,默認是1900 - 2050
      start:1950,
      end:2030
    }
   },
   components:{
    comCalendar:calendar
   },
   methods:{
    setDate:function () {
     //觸發(fā)日期組件
     this.$store.dispatch('calendarStatus',true);
    }
   },
    computed:{
     //遮罩狀態(tài)
     mark:function () {
      return this.$store.getters.markStatus
     },
     //組件狀態(tài)
     calendar:function () {
      return this.$store.getters.getCalendarStatus?{ display:'block'}:{ display:'none'};
     },
     //返回的日期
     date:function () {
      return this.$store.getters.getCalendarDate;
     }

    }

  }
  </script>

運行

# install dependencies
npm install

# serve with hot reload at localhost:8081
npm run dev

# build for production with minification
npm run build

版本

1.0.0 vue日期組件

demo地址:vue-calendar_jb51.rar

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論

恩平市| 东台市| 元氏县| 肥乡县| 定南县| 怀宁县| 康马县| 常宁市| 司法| 舟山市| 恩平市| 新乡县| 无锡市| 岑巩县| 浦城县| 渑池县| 炎陵县| 肃南| 连南| 顺义区| 荆州市| 浦城县| 荔波县| 鄂托克前旗| 句容市| 贡觉县| 洮南市| 通州区| 枣庄市| 邵阳市| 泊头市| 即墨市| 乌鲁木齐市| 阿克陶县| 苏尼特左旗| 元氏县| 岳阳县| 昂仁县| 琼中| 容城县| 绥滨县|