# san-xui
**Repository Path**: mirrors_ecomfe/san-xui
## Basic Information
- **Project Name**: san-xui
- **Description**: A Set of SAN UI Components that widely used on Baidu Cloud Console
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-08-08
- **Last Updated**: 2026-10-21
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
## san-xui
[](https://travis-ci.org/ecomfe/san-xui)
[](https://codecov.io/gh/ecomfe/san-xui/branch/master)
[](https://gemnasium.com/ecomfe/san-xui)
[](https://www.npmjs.org/package/san-xui)
[](https://npmjs.org/package/san-xui)
[](http://isitmaintained.com/project/ecomfe/san-xui "Percentage of issues still open")
[san-xui](http://ecomfe.github.io/san-xui/) 是基于 [san](http://ecomfe.github.io/san/) 开发的一套UI组件库,在[百度云的控制台](https://console.bce.baidu.com)中得到了广泛的应用。
## 下载
NPM:
```
npm i --save san-xui
```
## 使用
### AMD
这里使用的是 [esl](https://github.com/ecomfe/esl) 作为 AMD Loader,使用之前需要配置一下 paths 和 packages,如下:
```html
```
引入所需要的样式代码:
```html
```
最后是应用的代码:
```js
define(function(require) {
const san = require("san");
const { Button, alert } = require("san-xui");
const App = san.defineComponent({
template: `Hello san-xui`,
components: {
"ui-button": Button
},
onBtnClick() {
alert("Button clicked");
}
});
function start() {
const app = new App();
app.attach(document.getElementById("root"));
}
return { start };
});
```
最终的效果如下:
### Webpack
通过 named import 导入所需要使用的组件
```js
import 'san-xui/dist/xui.css';
import {defineComponent} from 'san';
import {Button} from 'san-xui';
// 引入单个的组件
import Button from 'san-xui/lib/x/components/Button';
const App = defineComponent({
template: `Hello san-xui`,
components: {
'ui-button': Button
}
});
const app = new App();
app.attach(document.body);
```
### webpack.config.js
需要安装必要的一些插件
```
npm i --save-dev babel-loader css-loader style-loader less-loader less file-loader babel-preset-stage-0 babel-preset-env
```
然后补充上一些相关的配置
```js
const path = require('path');
function alias(name) {
return path.dirname(require.resolve(name));
}
module.exports = {
...
resolve: {
mainFiles: ['index', 'main']
},
module: {
rules: [
{
test: /\.(png|gif|jpe?g|svg)$/,
use: [
{
loader: 'file-loader',
options: {
name(file) {
return 'assets/images/[hash].[ext]';
}
}
}
]
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.less$/,
use: [
{loader: 'style-loader'},
{loader: 'css-loader'},
{
loader: 'less-loader',
options: {
relativeUrls: true,
paths: []
}
}
]
},
{
test: /\.js$/,
exclude: /(node_modules|dist)/,
use: {
loader: 'babel-loader',
options: {
presets: ['env', 'stage-0']
}
}
}
]
},
...
}
```