Solve the problem that the element DateTimePicker+vue pop-up box only displays hours

Solve the problem that the element DateTimePicker+vue pop-up box only displays hours

Three knowledge points:

1. CSS descendant selector

https://www.w3school.com.cn/css/css_selector_descendant.asp

2.vue deep selector

https://vue-loader.vuejs.org/zh/guide/scoped-css.html

3.element ui DateTimePicker specifies the drop-down box class name popper-class

https://element.eleme.cn/#/zh-CN/component/datetime-picker

On the premise of understanding the above three knowledge points, in the global style of the vue page (that is, the style tag without the scoped mark), the css descendant selector + vue deep selector can be used to lock the style in the element ui component to be controlled, and the outer style class name is used to constrain the internal style of the element ui component to be controlled, so that all global element ui components will not be polluted.

However, DateTimePicker is special. The DOM of the pop-up box does not belong to any tag in the current Vue file, so it is not possible to use the CSS descendant selector + Vue deep selector to lock the pop-up box part of the DateTimePicker to be customized in the current page. By consulting the official documentation of DateTimePicker, I found that I can use popper-class to specify the class name of the drop-down box. In this way, you can use this specified class name + vue deep selector to uniquely rewrite the pop-up box part of a DateTimePicker that needs to be customized in the global style.

<template>
 <div class="app-container">
 
     <el-date-picker
      v-model="..."
      type="datetimerange"
      align="right"
      range-separator="to"
      start-placeholder="start time"
      end-placeholder="end time"
      format="yyyy-MM-dd HH"
      value-format="yyyy-MM-dd HH"
      popper-class="tpc"
     ></el-date-picker>
 
  </div>
</template>
<style lang="scss" scoped>
...
</style>
 
<style>
.tpc /deep/ .el-time-spinner__wrapper {
 width:100% !important;
}
.tpc /deep/ .el-scrollbar:nth-of-type(2) {
 display: none !important;
}
</style>

This is the end of this article about solving the problem of element DateTimePicker+vue pop-up box only showing hours. For more related element DateTimePicker pop-up box content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Example of Vue realizing click to display the pop-up box
  • Vue implements a simple login pop-up box
  • Implementation of universal pop-up box in Vue component development
  • Vue pop-up box component encapsulation example code
  • Use vue to implement various pop-up box components
  • ElementUI vue this.$confirm and el-dialog pop-up box mobile example demo
  • Vue component realizes the display and hide effect of pop-up box click
  • Detailed explanation of writing pop-up box components with Vue
  • Vue3 manual encapsulation pop-up box component message method

<<:  MySQL log settings and viewing methods

>>:  Detailed explanation of the correct way to configure SSL (https certificate) in Apache on Ubuntu

Recommend

What are the differences between xHTML and HTML tags?

All tags must be lowercase In XHTML, all tags must...

Detailed explanation of HTML page header code example

Knowledge point 1: Set the base URL of the web pa...

Analysis of the difference between emits and attrs in Vue3

Table of contents in conclusion Practice Analysis...

A brief discussion on the $notify points of element

My original intention was to encapsulate the $not...

WeChat applet realizes linkage menu

Recently, in order to realize the course design, ...

Detailed explanation of DOM style setting in four react components

1. Inline styles To add inline styles to the virt...

How to deploy MySQL master and slave in Docker

Download image Selecting a MySQL Image docker sea...

MySQL database terminal - common operation command codes

Table of contents 1. Add users 2. Change the user...

MySQL foreign key setting method example

1. Foreign key setting method 1. In MySQL, in ord...

CentOS 8 installation diagram (super detailed tutorial)

CentOS 8 is officially released! CentOS fully com...

Solution to the root password login problem in MySQL 5.7

After I found that the previous article solved th...

Setting the engine MyISAM/InnoDB when creating a data table in MySQL

When I configured mysql, I set the default storag...

A quick guide to Docker

Docker provides a way to automatically deploy sof...

Pure CSS3 realizes the effect of div entering and exiting in order

This article mainly introduces the effect of div ...

MySQL 8.0.22 download, installation and configuration method graphic tutorial

Download and install MySQL 8.0.22 for your refere...