
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
elastic-list
Advanced tools
v-model
el-table
[{}, {}]
)和原始类型数组([1, 2]
)element-ui 集成说明:
el-table
的所有参数(且可全局配置)el-table
的所有事件el-table
的所有slotel-table-column
以slot形式传入el-form
组件 支持 el-form
的全局 disablednpm add elastic-list
import 'elastic-list/dist/style.css'
import ElasticList from 'elastic-list'
// 局部引入
components: { ElasticList }
// 全局引入
Vue.use(ElasticList)
Example for el-table
<ElasticList v-model="value" :elTableProps="{}">
<el-table-column label="姓名" prop="name"/>
<el-table-column label="年龄" prop="age"/>
</ElasticList>
自定义操作列和添加按钮:
<ElasticList v-model="value">
<el-table-column label="姓名" prop="name"/>
<el-table-column label="年龄" prop="age"/>
<!-- the last column for row operation -->
<template #operation-column="{showDeleteButton,deleteRow}">
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<!-- other buttons -->
<el-button>其他按钮</el-button>
<!-- delete button -->
<el-button
type="danger"
circle
icon="el-icon-delete"
@click="() => { deleteRow(scope.$index) }"
v-show="showDeleteButton"
/>
</template>
</el-table-column>
</template>
<!-- add-row-trigger -->
<template v-slot:add-row-trigger="{addRow}">
<el-button @click="addRow">增加一行</el-button>
</template>
</ElasticList>
Example for lists
reference-type array:
<el-form :model="form">
<ElasticList v-model="form.list">
<template v-slot="{item,index,showDeleteButton,deleteRow}">
<div>
<!-- delete button -->
<i
class="el-icon-circle-close"
@click="deleteRow(index)"
v-show="showDeleteButton"
/>
<!-- editable elements -->
<el-form-item label="名称" :prop="'list.' + index + '.name'">
<el-input v-model="item.name"/>
</el-form-item>
<el-form-item label="排序" :prop="'list.' + index + '.sort'">
<el-input-number v-model="item.sort"/>
</el-form-item>
</div>
</template>
</ElasticList>
</el-form>
value-type array:
<ElasticList v-model="value">
<!--
v-slot解构:
index: {number} 行号
item: {any} 数组第i项
showDeleteButton: {boolean} 是否显示删除按钮
deleteRow: {function} 删除行
-->
<template v-slot="{item,index,showDeleteButton,deleteRow}">
<div>
<!-- row contents -->
<el-input v-model="value[index]"/>
<!-- delete button -->
<i v-show="showDeleteButton" class="el-icon-circle-close" @click="deleteRow(index)"/>
</div>
</template>
<!-- add-row-trigger -->
<template v-slot:add-row-trigger="{addRow}">
<el-button @click="addRow">自定义增加行按钮</el-button>
</template>
</ElasticList>
参数名 | 说明 | 类型 | 合法值 | 默认值 |
---|---|---|---|---|
v-model / value | 列表绑定值 | array | ||
elTableProps | el-table 配置 | object | ||
sortable | 是否开启拖拉拽排序 | boolean | true | |
disabled | 禁用模式下无法新增、删除、排序 | boolean | false | |
count | 行数限制 | number, [number, number] | ||
defaultRowValue | 新增行的默认值 | (item: any, index: number) => any | {} / '' | |
... | sortablejs 配置 |
默认值:
{
border: true,
fit: true,
stripe: true,
highlightCurrentRow: true,
}
配置方式:与默认值 进行混入
默认值:
{
filter: 'input,textarea,.el-rate',
preventOnFilter: false,
animation: 500,
}
配置方式:与默认值 进行混入
比如你想限制不能超过5行:
Vue.use(ElasticList, {
count: 5
})
如果你还想限制不能低于2行:
Vue.use(ElasticList, {
count: [2, 5]
})
如果没有指定,则会根据value的值推断使用 {}
或 ''
可以手动指定,支持 Function,Function 的返回值将作为新增项
组件内部会对其进行深拷贝
Vue.use(ElasticList, {
defaultRowValue (i) {
return i // i是新增的这一行的序号
}
})
名称 | 说明 |
---|---|
add-row-trigger | 增加行的触发按钮 |
operation-column | el-table 最后一列(用于删除行等操作) |
placeholder | value 为空时的占位符 |
... | el-table 所有 slot |
el-table
所有事件
<ElasticList
@select="onSelect"
@sort="onSort"
>
</ElasticList>
默认是整行均可以拖动 如果你想要指定触发元素:
<ElasticList v-model="value" handle=".handle">
<el-table-column type="index">
<template slot-scope="scope">
<span class="handle">
{{ '# ' + (scope.$index + 1) }}
</span>
</template>
</el-table-column>
<el-table-column label="姓名" prop="name"/>
</ElasticList>
由于在输入框内拖动时,用户的用意往往是选中输入内容而不是拖动排序,所以默认在输入框内不触发排序(可配置)
组件内不会监听非对象数组类型 value 的后续变化 如果 value 在初始化后需要修改,可使用以下方式:
为什么?
<template>
<div>
<ElasticList
ref="elasticList"
>
</ElasticList>
</div>
</template>
<script>
export default {
created () {
this.$POST().then(res => {
this.$refs.elasticList.setValue(res.data)
})
},
}
</script>
或者
<template>
<div>
<ElasticList
v-model="value"
v-if="loading"
>
</ElasticList>
</div>
</template>
<script>
export default {
data () {
return {
value: [],
loading: true
}
},
created () {
this.$POST()
.then(res => {
this.value = res.data
})
.finally(() => {
this.loading = false
})
},
}
</script>
FAQs
A drag-and-drop & editable table, custom list supported.
The npm package elastic-list receives a total of 2 weekly downloads. As such, elastic-list popularity was classified as not popular.
We found that elastic-list demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.