How does element's custom skin change function do?

element this page https://elementui.github.io/t., can support custom skin change, through the color selector can be customized to change the theme, do not know what the idea is, how to do it?
solving, it feels magical

Jul.01,2021

1 declare several variables for css preprocessing using less/scss

`@primary:-sharp0094ff;`

2 referencing this variable when writing component styles can also make some transformations based on this variable. For more information, please see the less/scss document
3 webpack packaged into css

.

so if you change a theme color variable, the packaged css color value will also change

< hr >

above is the original answer. Upstairs, I corrected the wrong question.
take a look at how element is implemented from the source code

.
theme(val, oldVal) {
        if (typeof val !== 'string') return;
        const themeCluster = this.getThemeCluster(val.replace('-sharp', ''));
        const originalCluster = this.getThemeCluster(oldVal.replace('-sharp', ''));
        const getHandler = (variable, id) => {
          return () => {
            const originalCluster = this.getThemeCluster(ORIGINAL_THEME.replace('-sharp', ''));
            let newStyle = this.updateStyle(this[variable], originalCluster, themeCluster);
            let styleTag = document.getElementById(id);
            if (!styleTag) {
              styleTag = document.createElement('style');
              styleTag.setAttribute('id', id);
              document.head.appendChild(styleTag);
            }
            styleTag.innerText = newStyle;
          };
        };

listens to the color value. If you change the color value, dynamically create a style tag to cascade the original style according to the current color value.
look at the element website console, you can find that at the beginning, there is no
id for docs-style and chalk-style style tags
change the color value, then there is
, so the theme has changed

.

vue instructions v-html, dynamically insert strings, as html tags, you can dynamically insert style tags.

implementation method:


        function test(m){
            document.documentElement.style.setProperty('--divHoverColor', m);
        }
    </script>
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3f047-2c441.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3f047-2c441.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?