|
40 | 40 | <!-- Form -->
|
41 | 41 | <el-button type="text" @click="dialogFormVisible = true">打开嵌套表单的 Dialog</el-button>
|
42 | 42 |
|
43 |
| - <el-dialog title="收货地址" :visible.sync="dialogFormVisible"> |
| 43 | + <el-dialog title="收货地址" :visible.sync="dialogFormVisible" class="dialogForm"> |
44 | 44 | <el-form :model="form">
|
45 | 45 | <el-form-item label="活动名称" :label-width="formLabelWidth">
|
46 | 46 | <el-input v-model="form.name" autocomplete="off"></el-input>
|
|
66 | 66 | </el-card>
|
67 | 67 | <el-card style="margin-bottom:50px;">
|
68 | 68 | <div slot="header">
|
69 |
| - <span>⾃定义时间戳</span> |
| 69 | + <span>嵌套的 Dialog</span> |
70 | 70 | </div>
|
71 | 71 | <el-row>
|
72 |
| - <div class="block"> |
73 |
| - <el-timeline> |
74 |
| - <el-timeline-item timestamp="2018/4/12" placement="top"> |
75 |
| - <el-card class="timeLineCard"> |
76 |
| - <h4>更新 Github 模板</h4> |
77 |
| - <p>王小虎 提交于 2018/4/12 20:46</p> |
78 |
| - </el-card> |
79 |
| - </el-timeline-item> |
80 |
| - <el-timeline-item timestamp="2018/4/3" placement="top"> |
81 |
| - <el-card class="timeLineCard"> |
82 |
| - <h4>更新 Github 模板</h4> |
83 |
| - <p>王小虎 提交于 2018/4/3 20:46</p> |
84 |
| - </el-card> |
85 |
| - </el-timeline-item> |
86 |
| - <el-timeline-item timestamp="2018/4/2" placement="top"> |
87 |
| - <el-card class="timeLineCard"> |
88 |
| - <h4>更新 Github 模板</h4> |
89 |
| - <p>王小虎 提交于 2018/4/2 20:46</p> |
90 |
| - </el-card> |
91 |
| - </el-timeline-item> |
92 |
| - </el-timeline> |
93 |
| - </div> |
| 72 | + <span class="demonstration">如果需要在一个 Dialog 内部嵌套另一个 Dialog,需要使用 append-to-body 属性</span> |
| 73 | + <template> |
| 74 | + <el-button type="text" @click="outerVisible = true">点击打开外层 Dialog</el-button> |
| 75 | + |
| 76 | + <el-dialog title="外层 Dialog" :visible.sync="outerVisible"> |
| 77 | + <el-dialog width="30%" title="内层 Dialog" :visible.sync="innerVisible" append-to-body> |
| 78 | + </el-dialog> |
| 79 | + <div slot="footer" class="dialog-footer"> |
| 80 | + <el-button @click="outerVisible = false">取 消</el-button> |
| 81 | + <el-button type="primary" @click="innerVisible = true">打开内层 Dialog</el-button> |
| 82 | + </div> |
| 83 | + </el-dialog> |
| 84 | + </template> |
| 85 | + </el-row> |
| 86 | + <el-collapse class="test" style="color:red;"> |
| 87 | + <el-collapse-item title="查看代码" name="2"> |
| 88 | + <div style="white-space: pre-wrap;">{{appendToBody}}</div> |
| 89 | + </el-collapse-item> |
| 90 | + </el-collapse> |
| 91 | + </el-card> |
| 92 | + <el-card style="margin-bottom:50px;"> |
| 93 | + <div slot="header"> |
| 94 | + <span>居中布局</span> |
| 95 | + </div> |
| 96 | + <el-row> |
| 97 | + <span class="demonstration">标题和底部可水平居中</span> |
| 98 | + <el-button type="text" @click="centerDialogVisible = true">点击打开 Dialog</el-button> |
| 99 | + |
| 100 | + <el-dialog title="提示" :visible.sync="centerDialogVisible" width="30%" center> |
| 101 | + <span>需要注意的是内容是默认不居中的</span> |
| 102 | + <span slot="footer" class="dialog-footer"> |
| 103 | + <el-button @click="centerDialogVisible = false">取 消</el-button> |
| 104 | + <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button> |
| 105 | + </span> |
| 106 | + </el-dialog> |
94 | 107 | </el-row>
|
95 | 108 | <el-collapse class="test" style="color:red;">
|
96 | 109 | <el-collapse-item title="查看代码" name="2">
|
97 |
| - <div style="white-space: pre-wrap;">{{placement}}</div> |
| 110 | + <div style="white-space: pre-wrap;">{{center}}</div> |
98 | 111 | </el-collapse-item>
|
99 | 112 | </el-collapse>
|
100 | 113 | </el-card>
|
|
105 | 118 | <script>
|
106 | 119 | export default {
|
107 | 120 | /* eslint-disable */
|
108 |
| - name: '', |
109 |
| - components: {}, |
110 |
| - data() { |
111 |
| - return { |
112 |
| - dialogVisible: false, |
113 |
| - gridData: [{ |
| 121 | + name: '', |
| 122 | + components: {}, |
| 123 | + data() { |
| 124 | + return { |
| 125 | + centerDialogVisible: false, |
| 126 | + outerVisible: false, |
| 127 | + innerVisible: false, |
| 128 | + dialogVisible: false, |
| 129 | + gridData: [{ |
| 130 | + date: '2016-05-02', |
| 131 | + name: '王小虎', |
| 132 | + address: '上海市普陀区金沙江路 1518 弄' |
| 133 | + }, { |
| 134 | + date: '2016-05-04', |
| 135 | + name: '王小虎', |
| 136 | + address: '上海市普陀区金沙江路 1518 弄' |
| 137 | + }, { |
| 138 | + date: '2016-05-01', |
| 139 | + name: '王小虎', |
| 140 | + address: '上海市普陀区金沙江路 1518 弄' |
| 141 | + }, { |
| 142 | + date: '2016-05-03', |
| 143 | + name: '王小虎', |
| 144 | + address: '上海市普陀区金沙江路 1518 弄' |
| 145 | + }], |
| 146 | + dialogTableVisible: false, |
| 147 | + dialogFormVisible: false, |
| 148 | + form: { |
| 149 | + name: '', |
| 150 | + region: '', |
| 151 | + date1: '', |
| 152 | + date2: '', |
| 153 | + delivery: false, |
| 154 | + type: [], |
| 155 | + resource: '', |
| 156 | + desc: '' |
| 157 | + }, |
| 158 | + formLabelWidth: '120px', |
| 159 | + base: ` |
| 160 | + <el-button type="text" @click="dialogVisible = true">点击打开 Dialog</el-button> |
| 161 | +
|
| 162 | +<el-dialog |
| 163 | + title="提示" |
| 164 | + :visible.sync="dialogVisible" |
| 165 | + width="30%" |
| 166 | + :before-close="handleClose"> |
| 167 | + <span>这是一段信息</span> |
| 168 | + <span slot="footer" class="dialog-footer"> |
| 169 | + <el-button @click="dialogVisible = false">取 消</el-button> |
| 170 | + <el-button type="primary" @click="dialogVisible = false">确 定</el-button> |
| 171 | + </span> |
| 172 | +</el-dialog> |
| 173 | +
|
| 174 | +<script> |
| 175 | + export default { |
| 176 | + data() { |
| 177 | + return { |
| 178 | + dialogVisible: false |
| 179 | + }; |
| 180 | + }, |
| 181 | + methods: { |
| 182 | + handleClose(done) { |
| 183 | + this.$confirm('确认关闭?') |
| 184 | + .then(_ => { |
| 185 | + done(); |
| 186 | + }) |
| 187 | + .catch(_ => {}); |
| 188 | + } |
| 189 | + } |
| 190 | + }; |
| 191 | +<\/script>`, |
| 192 | + diy: `<!-- Table --> |
| 193 | +<el-button type="text" @click="dialogTableVisible = true">打开嵌套表格的 Dialog</el-button> |
| 194 | +
|
| 195 | +<el-dialog title="收货地址" :visible.sync="dialogTableVisible"> |
| 196 | + <el-table :data="gridData"> |
| 197 | + <el-table-column property="date" label="日期" width="150"></el-table-column> |
| 198 | + <el-table-column property="name" label="姓名" width="200"></el-table-column> |
| 199 | + <el-table-column property="address" label="地址"></el-table-column> |
| 200 | + </el-table> |
| 201 | +</el-dialog> |
| 202 | +
|
| 203 | +<!-- Form --> |
| 204 | +<el-button type="text" @click="dialogFormVisible = true">打开嵌套表单的 Dialog</el-button> |
| 205 | +
|
| 206 | +<el-dialog title="收货地址" :visible.sync="dialogFormVisible"> |
| 207 | + <el-form :model="form"> |
| 208 | + <el-form-item label="活动名称" :label-width="formLabelWidth"> |
| 209 | + <el-input v-model="form.name" autocomplete="off"></el-input> |
| 210 | + </el-form-item> |
| 211 | + <el-form-item label="活动区域" :label-width="formLabelWidth"> |
| 212 | + <el-select v-model="form.region" placeholder="请选择活动区域"> |
| 213 | + <el-option label="区域一" value="shanghai"></el-option> |
| 214 | + <el-option label="区域二" value="beijing"></el-option> |
| 215 | + </el-select> |
| 216 | + </el-form-item> |
| 217 | + </el-form> |
| 218 | + <div slot="footer" class="dialog-footer"> |
| 219 | + <el-button @click="dialogFormVisible = false">取 消</el-button> |
| 220 | + <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button> |
| 221 | + </div> |
| 222 | +</el-dialog> |
| 223 | +
|
| 224 | +<script> |
| 225 | + export default { |
| 226 | + data() { |
| 227 | + return { |
| 228 | + gridData: [{ |
114 | 229 | date: '2016-05-02',
|
115 | 230 | name: '王小虎',
|
116 | 231 | address: '上海市普陀区金沙江路 1518 弄'
|
@@ -140,6 +255,61 @@ export default {
|
140 | 255 | desc: ''
|
141 | 256 | },
|
142 | 257 | formLabelWidth: '120px'
|
| 258 | + }; |
| 259 | + } |
| 260 | + }; |
| 261 | +<\/script>`, |
| 262 | + appendToBody: ` |
| 263 | +<template> |
| 264 | + <el-button type="text" @click="outerVisible = true">点击打开外层 Dialog</el-button> |
| 265 | +
|
| 266 | + <el-dialog title="外层 Dialog" :visible.sync="outerVisible"> |
| 267 | + <el-dialog |
| 268 | + width="30%" |
| 269 | + title="内层 Dialog" |
| 270 | + :visible.sync="innerVisible" |
| 271 | + append-to-body> |
| 272 | + </el-dialog> |
| 273 | + <div slot="footer" class="dialog-footer"> |
| 274 | + <el-button @click="outerVisible = false">取 消</el-button> |
| 275 | + <el-button type="primary" @click="innerVisible = true">打开内层 Dialog</el-button> |
| 276 | + </div> |
| 277 | + </el-dialog> |
| 278 | +</template> |
| 279 | +
|
| 280 | +<script> |
| 281 | + export default { |
| 282 | + data() { |
| 283 | + return { |
| 284 | + outerVisible: false, |
| 285 | + innerVisible: false |
| 286 | + }; |
| 287 | + } |
| 288 | + } |
| 289 | +<\/script>`, |
| 290 | +center: `<el-button type="text" @click="centerDialogVisible = true">点击打开 Dialog</el-button> |
| 291 | +
|
| 292 | +<el-dialog |
| 293 | + title="提示" |
| 294 | + :visible.sync="centerDialogVisible" |
| 295 | + width="30%" |
| 296 | + center> |
| 297 | + <span>需要注意的是内容是默认不居中的</span> |
| 298 | + <span slot="footer" class="dialog-footer"> |
| 299 | + <el-button @click="centerDialogVisible = false">取 消</el-button> |
| 300 | + <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button> |
| 301 | + </span> |
| 302 | +</el-dialog> |
| 303 | +
|
| 304 | +<script> |
| 305 | + export default { |
| 306 | + data() { |
| 307 | + return { |
| 308 | + centerDialogVisible: false |
| 309 | + }; |
| 310 | + } |
| 311 | + }; |
| 312 | +<\/script>` |
143 | 313 | };
|
144 | 314 | },
|
145 | 315 | // 计算属性设置
|
@@ -172,4 +342,8 @@ export default {
|
172 | 342 | font-size: 14px;
|
173 | 343 | margin-bottom: 20px;
|
174 | 344 | }
|
| 345 | +
|
| 346 | +.dialogForm /deep/ .el-select { |
| 347 | + width: 100%; |
| 348 | +} |
175 | 349 | </style>
|
0 commit comments