el-card去除阴影
html
<el-card style="box-shadow: none;">
</el-card>
el-button按钮加图标
html
<el-button type="primary" size="default" icon="Plus"
@click="addRole">添加职位</el-button>
el-table表头的文字居中
:header-cell-style="{textAlign: 'center'}"
、加边框 border
html
<el-table :data="PermisstionArr" style="width: 100%; margin-bottom: 20px" row-key="aid"
border :header-cell-style="{textAlign: 'center'}" >
<el-table-column label="名称" prop="aname"></el-table-column>
<el-table-column label="权限值" prop="code"></el-table-column>
<el-table-column label="修改时间" prop="updatetime"></el-table-column>
</el-table>
el-table树形结构默认展开 default-expand-all
html
<el-table :data="PermisstionArr" style="width: 100%; margin-bottom: 20px" row-key="aid"
border :header-cell-style="{textAlign: 'center'}" default-expand-all >
......
</el-table>
JS找出对象数组中某个key的所有value
javascript
let array = [
{ name: 'Apple', aid: 10101 },
{ name: 'Banana', aid: 10102 },
{ name: 'Cherry', aid: 10103 }
];
let allaid = array.map(item=>item.aid)
JS 从一个数组中删除另一个数组中不存在的元素
javascript
const aids = [
10101, 10102, 10103,
10104, 10201, 10202,
10203, 10301, 10302,
10303, 10304
]
const array = [10101, 22222]
22222 在aids中不存在,所以要把 22222 从array数组中剔除
javascript
function removeNonExistingElements(arr1, arr2) {
return arr1.filter(item => arr2.includes(item));
}
const result = removeNonExistingElements(aids , array );
JS 数组截取固定的值
csharp
array.slice(开始索引,结束索引)
vue3 控制台怎么不要提示vue warn
- main.ts
javascript
const app = createApp(App)
app.config.warnHandler=()=>null
el-tree
setCheckedKeys
setCurrentKey
html
<el-tree ref="tree">
</el-tree>
<script>
let tree = ref<any>();//获取tree组件实例
//清空选中的节点
tree.value.setCheckedKeys([])
</script>
el tree 获取选中节点 getCheckedNodes
javascript
tree.value.getCheckedNodes()