赞
踩
- <template>
- <view>
- <picker mode="date" fields="month" :value="date" @change="bindDateChange">
- <view class="uni-input">{{date}}</view>
- </picker>
- </view>
- </template>
-
- <script>
- export default {
- data() {
- return {
- date: this.getCurrentMonth()
- }
- },
- methods: {
- bindDateChange: function(e) {
- this.date = e.target.value
- console.log(this.date)
- },
-
- getCurrentMonth () {
- const date = new Date()
- let year = date.getFullYear()
- let month = date.getMonth() + 1
- month = month > 9 ? month : '0' + month
- return `${year}-${month}`
- }
- }
- }
- </script>
-
- <style>
-
- </style>
picker | uni-app官网https://uniapp.dcloud.io/component/picker.html#picker
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。