Bootstrap 5 「整理后删除」

bootstrap 5

<script setup>
const loadTheme = (themeName) => {
  // 移除现有的主题link标签
  const existingLink = document.getElementById('theme-style');
  if (existingLink) {
    existingLink.remove();
  }
  
  // 创建新的link标签
  const link = document.createElement('link');
  link.id = 'theme-style';
  link.rel = 'stylesheet';
  link.href = `/themes/${themeName}.css`;
  
  // 添加到head
  document.head.appendChild(link);
};

// 使用示例
loadTheme('dark'); // 加载dark.css
</script>

# bootstrap 5

- 资料:
  - 官网: [https://getbootstrap.com](https://getbootstrap.com)
- bootstrap 样式网站: [https://bootswatch.com/](https://bootswatch.com/)
- nuxt3 网站更换css样式文件

```javascript
<script setup>
const loadTheme = (themeName) => {
  // 移除现有的主题link标签
  const existingLink = document.getElementById('theme-style');
  if (existingLink) {
    existingLink.remove();
  }
  
  // 创建新的link标签
  const link = document.createElement('link');
  link.id = 'theme-style';
  link.rel = 'stylesheet';
  link.href = `/themes/${themeName}.css`;
  
  // 添加到head
  document.head.appendChild(link);
};

// 使用示例
loadTheme('dark'); // 加载dark.css
</script>
```