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

Analysis of the operating principle and implementation process of Docker Hub

Similar to the code hosting service provided by G...

Example of removing json backslash in php

1. Remove backslashes through the "stripslas...

Implementation of multi-environment configuration (.env) of vue project

Table of contents What is multi-environment confi...

How to build a private Docker repository using Harbor

Table of contents 1. Open source warehouse manage...

Real-time refresh of long connection on Vue+WebSocket page

Recently, the Vue project needs to refresh the da...

Detailed introduction to JS basic concepts

Table of contents 1. Characteristics of JS 1.1 Mu...

CSS3 gradient background compatibility issues

When we make a gradient background color, we will...

How to make React components full screen

introduce This article is based on React + antd t...

Is it necessary to give alt attribute to img image tag?

Do you add an alt attribute to the img image tag? ...

DOCTYPE type detailed introduction

<br />We usually declare DOCTYPE in HTML in ...

A brief discussion on the three major issues of JS: asynchrony and single thread

Table of contents Single thread asynchronous Sing...

How many common loops do you know about array traversal in JS?

Preface As a basic data structure, arrays and obj...

setup+ref+reactive implements vue3 responsiveness

Setup is used to write combined APIs. The interna...