less.modifyVars改顏色主題


index.html增加

<link rel="stylesheet/less" type="text/css" href="theme.less" />

  

theme.less文件內容:
@primary-color: #000;
body {
  background-color: @primary-color;
}

  

想再哪個頁面有:

先引入less

import less from 'less'; 

再使用

public componentDidMount() {
    setTimeout(() => {
      less.modifyVars({
        '@primary-color': 'red',
      });
    }, 5000);
  }

  

用setTimeout模擬了按鈕點擊,具體邏輯自己加


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM