iis服务器助手广告广告
返回顶部
首页 > 资讯 > 精选 >使用vue怎么实现一个价格日历效果
  • 871
分享到

使用vue怎么实现一个价格日历效果

2023-06-14 20:06:44 871人浏览 独家记忆
摘要

今天就跟大家聊聊有关使用Vue怎么实现一个价格日历效果,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。Vue的优点Vue具体轻量级框架、简单易学、双向数据绑定、组件化、数据和结构的分离

今天就跟大家聊聊有关使用Vue怎么实现一个价格日历效果,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

Vue的优点

Vue具体轻量级框架、简单易学、双向数据绑定、组件化、数据和结构的分离、虚拟DOM、运行速度快等优势,Vue中页面使用的是局部刷新,不用每次跳转页面都要请求所有数据和dom,可以大大提升访问速度和用户体验。

<template>  <div >    <ele-calendar      :render-content="renderContent"      :data="datedef"      :prop="prop"      :disabledDate="disabledDate"      :effectiveTimeLimit="effectiveTimeLimit"      :defaultValue="defaultValue"    >    </ele-calendar>  </div></template><script>import eleCalendar from 'ele-calendar'import 'ele-calendar/dist/vue-calendar.CSS'export default {  props: {    datedef: {      type: Array,      default: () => {        return []      }    },    defaultPrice: {      type: String,      default: () => {        return ''      }    },    effectiveTimeLimit: {      type: String,      default: () => {        return ''      }    },    defaultValue: {      type: Date,      default: () => {        return new Date()      }    }  },  data () {    const self = this    return {      prop: 'date', // 对应日期字段名      disabledDate: date => {        return (          date.valueOf() < new Date().valueOf() - 1 * 24 * 60 * 60 * 1000 ||          date.valueOf() > new Date(self.effectiveTimeLimit).valueOf()        )      }    }  },  components: {    eleCalendar  },  methods: {    //  jsX语法    renderContent (h, parmas) {      const self = this      const loop = data => {        return (          <div class={data.defvalue.value ? 'active' : ''}>            <div>{data.defvalue.text}</div>            <div>              ¥            <i-input              value={                data.defvalue.value.content                  ? data.defvalue.value.content                  : self.defaultPrice              }              on-on-blur={event =>                self.handleChange(                  event,                  data.defvalue.value                    ? data.defvalue.value.date                    : self.handleDate(data.defdate)                )              }              disabled={                data.defvalue.value                  ? new Date(data.defvalue.value.date).valueOf() <                        new Date().valueOf() - 1 * 24 * 60 * 60 * 1000 ||                      new Date(data.defvalue.value.date).valueOf() >                        new Date(self.effectiveTimeLimit).valueOf()                  : data.defdate.valueOf() <                        new Date().valueOf() - 1 * 24 * 60 * 60 * 1000 ||                      data.defdate.valueOf() >                        new Date(self.effectiveTimeLimit).valueOf()              }              key={                data.defvalue.value                  ? data.defvalue.value.date                  : self.handleDate(data.defdate)              }            />            </div>          </div>        )      }      return <div style='min-height:60px;'>{loop(parmas)}</div>    },    handleChange (event, date) {      console.log(event, date, 'DDDddd')      const self = this      const index = self.datedef.findIndex(item => {        return item.date === date      })      if (isNaN(event.target.value)) {        self.$Message.error('请输入正确的价格')        event.target.value = self.defaultPrice        return      }      if (event.target.value && index === -1) {        if (event.target.value === self.defaultPrice) {          return        }        self.datedef.push({          date,          content: event.target.value,          cid: null        })        console.log('self.datedef', self.datedef)        this.$emit('aaa', self.datedef)      } else if (event.target.value && index !== -1) {        if (event.target.value === self.defaultPrice) {          self.datedef.splice(index, 1)          return        }        const selectItem = self.datedef[index]        selectItem.content = event.target.value        self.datedef.splice(index, 1, selectItem)      } else if (!event.target.value && index !== -1) {        self.datedef.splice(index, 1)      } else {        event.target.value = self.defaultPrice      }    },    handleDate (date) {      const year = date.getFullYear()      let month = date.getMonth() + 1      month = month >= 10 ? month : '0' + month      let idate = date.getDate()      idate = idate >= 10 ? idate : '0' + idate      return `${year}-${month}-${idate}`    }  }}</script><style lang="scss">.el-picker-panel-calendar.el-date-picker-calendar.el-popper {  box-shadow: none;}.el-date-table-calendar td > div > div {  border: 1px solid #aaa;  color: #fff;  margin: 5px;  & > div:first-child {    background-color: #aaa;  }  & > div:nth-child(2) {    padding: 5px;    color: #000;    .ivu-input-wrapper {      width: 80%;    }  }  &.active {    border: 1px solid #2ab561;    & > div:first-child {      background-color: #2ab561;    }    & > div:nth-child(2) {      padding: 5px;      color: #000;      .ivu-input-wrapper {        width: 80%;      }    }  }}// 这段如果放开的话当天之前的所有框置灰// .el-date-table-calendar td.disabled > div > div {//   border: 1px solid #aaa;//   color: #fff;//   margin: 5px;//   & > div:first-child {//     background-color: #aaa;//   }//   & > div:nth-child(2) {//     padding: 5px;//     color: #000;//     .ivu-input-wrapper {//       width: 80%;//     }//   }// }.el-date-table-calendar td.available:hover {  color: #000;}.el-date-table-calendar td.available.today {  color: #000;  font-weight: nORMal;}.el-date-table-calendar tr td.current.available:not(.disabled) {  background-color: #fff;}</style>

页面引入注册

<script> import calendar from '../../components/calendar' export default {    components: { calendar}  }  data() {    return {      effectiveTimeLimit: '',      ruleForm: {        price: '',        configPriceList: []      }      },      rules: {      } }    }</script>

html

我是写在dialog中的

<el-form-item label="价格设置" prop="calendarPrice"> <calendar :datedef="ruleForm.configPriceList" :default-price="ruleForm.price" :effectiveTimeLimit="effectiveTimeLimit" ></calendar></el-form-item>

看完上述内容,你们对使用vue怎么实现一个价格日历效果有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注编程网精选频道,感谢大家的支持。

--结束END--

本文标题: 使用vue怎么实现一个价格日历效果

本文链接: https://www.lsjlt.com/news/275092.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • C++ 生态系统中流行库和框架的贡献指南
    作为 c++++ 开发人员,通过遵循以下步骤即可为流行库和框架做出贡献:选择一个项目并熟悉其代码库。在 issue 跟踪器中寻找适合初学者的问题。创建一个新分支,实现修复并添加测试。提交...
    99+
    2024-05-14
    框架 c++ 流行库 git
  • C++ 生态系统中流行库和框架的社区支持情况
    c++++生态系统中流行库和框架的社区支持情况:boost:活跃的社区提供广泛的文档、教程和讨论区,确保持续的维护和更新。qt:庞大的社区提供丰富的文档、示例和论坛,积极参与开发和维护。...
    99+
    2024-05-14
    生态系统 社区支持 c++ overflow 标准库
  • c++中if elseif使用规则
    c++ 中 if-else if 语句的使用规则为:语法:if (条件1) { // 执行代码块 1} else if (条件 2) { // 执行代码块 2}// ...else ...
    99+
    2024-05-14
    c++
  • c++中的继承怎么写
    继承是一种允许类从现有类派生并访问其成员的强大机制。在 c++ 中,继承类型包括:单继承:一个子类从一个基类继承。多继承:一个子类从多个基类继承。层次继承:多个子类从同一个基类继承。多层...
    99+
    2024-05-14
    c++
  • c++中如何使用类和对象掌握目标
    在 c++ 中创建类和对象:使用 class 关键字定义类,包含数据成员和方法。使用对象名称和类名称创建对象。访问权限包括:公有、受保护和私有。数据成员是类的变量,每个对象拥有自己的副本...
    99+
    2024-05-14
    c++
  • c++中优先级是什么意思
    c++ 中的优先级规则:优先级高的操作符先执行,相同优先级的从左到右执行,括号可改变执行顺序。操作符优先级表包含从最高到最低的优先级列表,其中赋值运算符具有最低优先级。通过了解优先级,可...
    99+
    2024-05-14
    c++
  • c++中a+是什么意思
    c++ 中的 a+ 运算符表示自增运算符,用于将变量递增 1 并将结果存储在同一变量中。语法为 a++,用法包括循环和计数器。它可与后置递增运算符 ++a 交换使用,后者在表达式求值后递...
    99+
    2024-05-14
    c++
  • c++中a.b什么意思
    c++kquote>“a.b”表示对象“a”的成员“b”,用于访问对象成员,可用“对象名.成员名”的语法。它还可以用于访问嵌套成员,如“对象名.嵌套成员名.成员名”的语法。 c++...
    99+
    2024-05-14
    c++
  • C++ 并发编程库的优缺点
    c++++ 提供了多种并发编程库,满足不同场景下的需求。线程库 (std::thread) 易于使用但开销大;异步库 (std::async) 可异步执行任务,但 api 复杂;协程库 ...
    99+
    2024-05-14
    c++ 并发编程
  • 如何在 Golang 中备份数据库?
    在 golang 中备份数据库对于保护数据至关重要。可以使用标准库中的 database/sql 包,或第三方包如 github.com/go-sql-driver/mysql。具体步骤...
    99+
    2024-05-14
    golang 数据库备份 mysql git 标准库
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作