国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

基于vue2.0+vuex的日期選擇組件功能實現

2019-11-19 17:10:11
字體:
來源:轉載
供稿:網友

calendar vue日期選擇組件

一個選擇日期的vue組件

基于vue2.0 + vuex

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

demo展示&&項目中的使用

目錄結構

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

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

組件使用

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

觸發組件 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 () {     //觸發日期組件     this.$store.dispatch('calendarStatus',true);    }   },    computed:{     //遮罩狀態     mark:function () {      return this.$store.getters.markStatus     },     //組件狀態     calendar:function () {      return this.$store.getters.getCalendarStatus?{ display:'block'}:{ display:'none'};     },     //返回的日期     date:function () {      return this.$store.getters.getCalendarDate;     }    }  }  </script>

運行

# install dependenciesnpm install# serve with hot reload at localhost:8081npm run dev# build for production with minificationnpm run build

版本

1.0.0 vue日期組件

demo地址:vue-calendar_jb51.rar

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 滨州市| 宜都市| 普宁市| 玉树县| 英超| 车险| 朝阳县| 大竹县| 兰坪| 兰溪市| 长寿区| 积石山| 柞水县| 南通市| 沁水县| 锡林浩特市| 焉耆| 汽车| 平安县| 阳谷县| 花莲市| 开平市| 射阳县| 德钦县| 深泽县| 青田县| 潜山县| 津市市| 仁怀市| 周口市| 稻城县| 肥东县| 秦皇岛市| 宿迁市| 于都县| 特克斯县| 张家界市| 丰台区| 尉犁县| 塔城市| 塘沽区|