elementui中的el-row和el-col的使用規范
問題:在el-row標簽中,包含了el-col和el-row。結果導致此布局中的表單元素無法使用的問題,如下:
1 <template>
2 <el-row>
3 <el-col :span="8">Column 3</el-col>
4 <el-col :span="8">Column 4</el-col>
5 <el-col :span="8">
6 <el-row>
<el-form-item label="活動名稱">
<el-input v-model="form.name"></el-input>
</el-form-item>
</el-row>
7 </el-col>
8 </el-row>
9 </template>
結果:活動名稱這個輸入框無法輸入內容。
注意:通常情況下,el-row 應該直接包裹多個 el-col 組件,而不是嵌套另一個 el-row。
如果你想在頁面中創建嵌套的網格布局,你可以直接在 el-row 中使用多個 el-col,然后在某個 el-col 中再嵌套另一個 el-row 和其內部的 el-col。
以下是正確規范的代碼:
(1)普通用法:
1 <el-row> 2 <el-col :span="12">內容</el-col> 3 <el-col :span="12">內容</el-col> 4 </el-row>
(2)嵌套用法:
1 <template> 2 <el-row> 3 <el-col :span="8"> 4 <el-row> 5 <el-col :span="12">Column 1</el-col> 6 <el-col :span="12">Column 2</el-col> 7 </el-row> 8 </el-col> 9 <el-col :span="8">Column 3</el-col> 10 <el-col :span="8">Column 4</el-col> 11 </el-row> 12 </template>

浙公網安備 33010602011771號