前端工程化的CSS预处理工具之Stylus

简介: Stylus是一个非常流行的前端工程化打包工具,它可以帮助开发者快速构建具有可重用性和可维护性的前端项目,并且提供了完善的样式规则和自动化处理机制。

其中,Stylus的Task是一个非常重要的概念。 下面是一个简单的示例,演示如何在Vue.js中注册一个名为HelloWorld的组件,并使用Stylus进行组件开发,并实现Task。

html

Copy code

<template>  <div>    <divv-if="isLoading"class="loading-spinner">Loading...</div>    <divv-if="isVisible"class="visible-content">点击我</div>  </div></template><script>import HelloWorld from'./HelloWorld.vue'exportdefault {  data() {    return {      isLoading: true,      isVisible: false,    }  },  mounted() {    setTimeout(() => {      this.isLoading = false      this.isVisible = true    }, 1000)  }}</script><scriptsrc="https://unpkg.com/react@16.8.3/umd/react.development.js"></script><style>.loading-spinner {  position: absolute;  top: 50%;  left: 50%;  width: 50px;  height: 50px;  border-radius: 50%;  background-color: #ccc;  animation: spin 1s linear infinite;}@keyframes spin {  0% {    transform: rotate(0deg);  }  100% {    transform: rotate(360deg);  }}</style><React.createElement>  <divclassName="App">    <HelloWorld />    <divclassName="nav">      <ul>        <li><Linkto="/">首页</Link></li>        <li><Linkto="/about">关于</Link></li>      </ul>    </div>  </div></React.createElement><scriptsrc="https://unpkg.com/react-router-dom@4.3.3/umd/react-router-dom.development.js"></script><style>.App {  display: flex;  flex-direction: column;  align-items: center;  padding: 20px;}.nav {  display: flex;  flex-direction: column;  align-items: center;  margin-bottom: 20px;}.navli {  padding: 10px;  font-size: 16px;  text-align: center;}.nava {  color: #333;  text-decoration: none;}.nava:hover {  background-color: #333;}</style><scriptsrc="https://unpkg.com/vue@2.6.11/dist/vue.min.js"></script><style>.loading-spinner {  position: absolute;  top: 50%;  left: 50%;  width: 50px;  height: 50px;  border-radius: 50%;  background-color: #ccc;  animation: spin 1s linear infinite;}@keyframes spin {  0% {    transform: rotate(0deg);  }  100% {    transform: rotate(360deg);  }}</style><scriptsrc="https://unpkg.com/vue-router@1.7.2/dist/vue-router.min.js"></script><style>.App {  display: flex;  flex-direction: column;  align-items: center;  padding: 20px;}.nav {  display: flex;  flex-direction: column;  align-items: center;  margin-bottom: 20px;}.navli {  padding: 10px;  font-size: 16px;  text-align: center;}.nava {  color: #333;  text-decoration: none;}.nava:hover {  background-color: #333;}</style><scriptsrc="https://unpkg.com/vue-router-link-active@1.0.5/dist/vue-router-link-active.min.js"></script><scriptsrc="https://unpkg.com/axios@0.20.0/dist/axios.min.js"></script><style>.loading-spinner {  position: absolute;  top: 50%;  left: 50%;  width: 50px;  height: 50px;  border-radius: 50%;  background-color: #ccc;  animation: spin 1s linear infinite;}@keyframes spin {  0% {    transform: rotate(0deg);  }  100% {    transform: rotate(360deg);  }}</style><scriptsrc="https://unpkg.com/vue-router-link-active@1.0.5/dist/vue-router-link-active.min.js"></script><scriptsrc="https://unpkg.com/axios@0.20.0/dist/axios.min.js"></script><style>.App {  display: flex;  flex-direction: column;  align-items: center;  padding: 20px;}.nav {  display: flex;  flex-direction: column;  align-items: center;  margin-bottom: 20px;}.navli {  padding: 10px;  font-size: 16px;  text-align: center;}.nava {  color: #333;  text-decoration: none;}.nava:hover {  background-color:

目录
相关文章
|
23天前
|
缓存 前端开发
前端代码整洁与规范之CSS篇
【4月更文挑战第2天】 前端代码整洁与规范之CSS篇
41 4
|
1天前
|
前端开发 JavaScript 开发者
深入了解Webpack:前端模块打包工具
深入了解Webpack:前端模块打包工具
8 1
|
11天前
|
移动开发 前端开发 JavaScript
CSS选择器 前端开发入门笔记(十)
CSS选择器 前端开发入门笔记(十)
19 1
|
11天前
|
前端开发 搜索推荐 数据安全/隐私保护
HTML标签详解 HTML5+CSS3+移动web 前端开发入门笔记(四)
HTML标签详解 HTML5+CSS3+移动web 前端开发入门笔记(四)
18 1
|
15天前
|
前端开发 JavaScript 搜索推荐
CSS框架是前端开发中不可或缺的工具
【4月更文挑战第12天】CSS框架是前端开发中不可或缺的工具
18 2
|
24天前
|
人工智能 前端开发 JavaScript
【前端设计】HTML+CSS+JavaScript基本特性
【前端设计】HTML+CSS+JavaScript基本特性
|
1月前
|
前端开发 UED 开发者
探索前端开发中的CSS布局技巧
本文将介绍一些在前端开发中常用的CSS布局技巧,包括盒模型、浮动布局、弹性布局和栅格系统等。通过学习这些技巧,开发者可以更加灵活地控制页面的布局,提升用户体验和界面的美观性。
|
1月前
|
前端开发 JavaScript 开发者
前端的CSS选择器
前端的CSS选择器
23 1
|
8月前
|
Web App开发 前端开发 JavaScript
前端学习笔记202307学习笔记第五十七天-模拟面试笔记react-fiber解决了什么问题
前端学习笔记202307学习笔记第五十七天-模拟面试笔记react-fiber解决了什么问题
95 0