# 使用
# React
下面是一个简单的完整例子:
目录结构
test
|- index.html
|- index.js
1
2
3
2
3
index.html
<!DOCTYPE html>
<html lang="zh-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Slug Antd</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
index.js
import React from 'react'
import ReactDOM from 'react-dom'
import { Layout, Menu } from 'antd'
import { SadHeader } from '@tencent/slug-antd-react'
import 'antd/dist/antd.css'
ReactDOM.render(
<Layout className="slug-antd">
<SadHeader className="header"
logo={
<a className="home" href="/" >
<div className="logo"></div>
<h1>互娱营销云</h1>
</a>
}>
<Menu className="menu"
theme="dark"
mode="horizontal">
<Menu.Item>
<a target="_blank" href="https://moss.oa.com/docs/">使用手册</a>
</Menu.Item>
</Menu>
</SadHeader>
</Layout>,
document.getElementById('root')
)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Vue
下面是一个简单的完整例子:
目录结构
test
|- app.vue
|- index.html
|- index.js
1
2
3
4
2
3
4
index.html
<!DOCTYPE html>
<html lang="zh-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Slug Antd</title>
</head>
<body>
<div id="slug-antd"></div>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
index.js
import Vue from 'vue'
import Antd from 'ant-design-vue'
import SlugAntd from '@tencent/slug-antd-vue'
import App from './app.vue'
import 'ant-design-vue/dist/antd.css'
Vue.use(Antd)
Vue.use(SlugAntd)
window.vm = new Vue({
el: '#slug-antd',
render: h => h(App)
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
app.vue
<template>
<a-layout>
<sad-header class="slug-antd">
<template #logo>
<a class="home" href="/" >
<div class="logo"></div>
<h1>互娱营销云</h1>
</a>
</template>
<a-menu class="menu"
theme="dark" mode="horizontal">
<a-menu-item key="使用手册">
<a target="_blank" href="https://moss.oa.com/docs/">使用手册</a>
</a-menu-item>
</a-menu>
</sad-header>
</a-layout>
</template>
<script>
export default {
name: 'demo',
}
</script>
<style lang="postcss">
.slug-antd {
> .home {
flex: none;
display: flex;
align-items: center;
.logo {
width: 32px;
height: 32px;
background: url(../../../src/images/logo.png) no-repeat center / contain;
}
h1 {
margin: 0 12px;
font-size: 1.5em;
color: #fff;
}
}
> .menu {
line-height: 64px;
}
}
</style>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47