|
2 | 2 | --- |
3 | 3 | order: 0 |
4 | 4 | title: |
5 | | - en-US: Basic Usage |
6 | 5 | zh-CN: 基本用法 |
| 6 | + en-US: Basic usage |
7 | 7 | --- |
8 | 8 |
|
9 | 9 | ## zh-CN |
10 | 10 |
|
11 | | -简单的表格,最后一列是各种操作。 |
| 11 | +第一个对话框。 |
12 | 12 |
|
13 | 13 | ## en-US |
14 | 14 |
|
15 | | -Simple table with actions. |
| 15 | +Basic modal. |
| 16 | + |
16 | 17 | </docs> |
17 | 18 |
|
18 | 19 | <template> |
19 | | - <a-table :columns="columns" :data-source="data"> |
20 | | - <template #headerCell="{ title, column }"> |
21 | | - <template v-if="column.key === 'name'"> |
22 | | - <span> |
23 | | - <smile-outlined /> |
24 | | - Name |
25 | | - </span> |
26 | | - </template> |
27 | | - <template v-else>{{ title }}</template> |
28 | | - </template> |
29 | | - |
30 | | - <template #bodyCell="{ column, record }"> |
31 | | - <template v-if="column.key === 'name'"> |
32 | | - <a> |
33 | | - {{ record.name }} |
34 | | - </a> |
35 | | - </template> |
36 | | - <template v-else-if="column.key === 'tags'"> |
37 | | - <span> |
38 | | - <a-tag |
39 | | - v-for="tag in record.tags" |
40 | | - :key="tag" |
41 | | - :color="tag === 'loser' ? 'volcano' : tag.length > 5 ? 'geekblue' : 'green'" |
42 | | - > |
43 | | - {{ tag.toUpperCase() }} |
44 | | - </a-tag> |
45 | | - </span> |
46 | | - </template> |
47 | | - <template v-else-if="column.key === 'action'"> |
48 | | - <span> |
49 | | - <a>Invite 一 {{ record.name }}</a> |
50 | | - <a-divider type="vertical" /> |
51 | | - <a>Delete</a> |
52 | | - <a-divider type="vertical" /> |
53 | | - <a class="ant-dropdown-link"> |
54 | | - More actions |
55 | | - <down-outlined /> |
56 | | - </a> |
57 | | - </span> |
58 | | - </template> |
59 | | - <template v-else>{{ record.name }}</template> |
60 | | - </template> |
61 | | - </a-table> |
| 20 | + <div> |
| 21 | + <div ref="container"></div> |
| 22 | + <a-button type="primary" @click="showModal">Open Modal</a-button> |
| 23 | + <a-modal v-model:visible="visible" title="Basic Modal" @ok="handleOk"> |
| 24 | + <p>Some contents...</p> |
| 25 | + <p>Some contents...</p> |
| 26 | + <p>Some contents...</p> |
| 27 | + </a-modal> |
| 28 | + </div> |
62 | 29 | </template> |
63 | 30 | <script lang="ts"> |
64 | | -import { SmileOutlined, DownOutlined } from '@ant-design/icons-vue'; |
65 | | -import { defineComponent } from 'vue'; |
66 | | -const columns = [ |
67 | | - { |
68 | | - name: 'Name', |
69 | | - dataIndex: 'name', |
70 | | - key: 'name', |
71 | | - }, |
72 | | - { |
73 | | - title: 'Age', |
74 | | - dataIndex: 'age', |
75 | | - key: 'age', |
76 | | - }, |
77 | | - { |
78 | | - title: 'Address', |
79 | | - dataIndex: 'address', |
80 | | - key: 'address', |
81 | | - }, |
82 | | - { |
83 | | - title: 'Tags', |
84 | | - key: 'tags', |
85 | | - dataIndex: 'tags', |
86 | | - }, |
87 | | - { |
88 | | - title: 'Action', |
89 | | - key: 'action', |
90 | | - }, |
91 | | -]; |
92 | | -
|
93 | | -const data = [ |
94 | | - { |
95 | | - key: '1', |
96 | | - name: 'John Brown', |
97 | | - age: 32, |
98 | | - address: 'New York No. 1 Lake Park', |
99 | | - tags: ['nice', 'developer'], |
100 | | - }, |
101 | | - { |
102 | | - key: '2', |
103 | | - name: 'Jim Green', |
104 | | - age: 42, |
105 | | - address: 'London No. 1 Lake Park', |
106 | | - tags: ['loser'], |
107 | | - }, |
108 | | - { |
109 | | - key: '3', |
110 | | - name: 'Joe Black', |
111 | | - age: 32, |
112 | | - address: 'Sidney No. 1 Lake Park', |
113 | | - tags: ['cool', 'teacher'], |
114 | | - }, |
115 | | -]; |
116 | | -
|
| 31 | +import { defineComponent, ref } from 'vue'; |
117 | 32 | export default defineComponent({ |
118 | | - components: { |
119 | | - SmileOutlined, |
120 | | - DownOutlined, |
121 | | - }, |
122 | 33 | setup() { |
| 34 | + const visible = ref<boolean>(false); |
| 35 | +
|
| 36 | + const showModal = () => { |
| 37 | + visible.value = true; |
| 38 | + }; |
| 39 | +
|
| 40 | + const handleOk = (e: MouseEvent) => { |
| 41 | + console.log(e); |
| 42 | + visible.value = false; |
| 43 | + }; |
| 44 | + const container = ref(); |
123 | 45 | return { |
124 | | - data, |
125 | | - columns, |
| 46 | + container, |
| 47 | + visible, |
| 48 | + showModal, |
| 49 | + handleOk, |
| 50 | + getContainer() { |
| 51 | + console.log('container', container.value); |
| 52 | + return container.value; |
| 53 | + }, |
126 | 54 | }; |
127 | 55 | }, |
128 | 56 | }); |
|
0 commit comments