做项目过程中问题小汇总 | vue3 elementplus js

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()
相关推荐
A黄俊辉A5 天前
uniapp webview中实现 app和内嵌的H5双向通信
vue.js·json
三十而立洋5 天前
Cookie 详解:从产生到安全,一次讲透
前端·javascript
卡布鲁5 天前
把一个 Vite + Vue3 应用塞进 qiankun (React + Umi3) 主站:十个坑的复盘
前端·javascript·react.js
李少兄5 天前
JavaScript 隐式全局变量解析
javascript
honkun65 天前
vue 表格组件 vxe-table 配置 ajax 请求自动加载数据与表单查询
vue.js·vxe-table
kybs19915 天前
全球灾害数据分析可视化 毕业设计-附源码66794
vue.js·spring boot·mysql·安全·django·c#·asp.net
雪芽蓝域zzs5 天前
第26章:ECharts 自定义主题 + 页面一键切换主题(深色 / 浅色两套)
vue.js·echars
雪芽蓝域zzs5 天前
第22章:ECharts 图表联动(多图表交互联动)
vue.js·echars
daols885 天前
vue 表格组件 vxe-table 实现虚拟滚动与无需滚动加载
vue.js·vxe-table
雪芽蓝域zzs5 天前
第18章:ECharts 折线图 + 标记点、标记线,自定义 tooltip
vue.js·echars