提交 5c265965 编写于 作者: Cano1997's avatar Cano1997

update:搜索栏组件

上级 a10b5b6f
......@@ -22,6 +22,9 @@
gap: 16px;
img {
cursor: pointer;
&.is-disabled {
cursor: not-allowed;
}
}
}
.app-searchbar-field {
......
......@@ -17,7 +17,7 @@
</div>
<div class="app-searchbar-action">
<img src="assets/img/add.svg" @click="onAddItem()">
<img src="assets/img/remove.svg" @click="onRemoveItem(index)">
<img :class="{'is-disabled': items.length == 1}" src="assets/img/remove.svg" @click="onRemoveItem(index)">
</div>
</div>
</div>
......@@ -51,6 +51,17 @@ export default class AppSearchbar extends Vue {
*/
@Prop() fields: any;
@Watch('items',{immediate: true})
onItemsChange(newItems: any[]) {
if (newItems.length == 0) {
this.items.push({
field: null,
mode: null,
editor: null
})
}
}
/**
* 属性项集合
*
......@@ -69,9 +80,6 @@ export default class AppSearchbar extends Vue {
if(!this.fields) {
return;
}
if (this.items.length === 0) {
this.onAddItem();
}
this.fields.forEach((field: any) => {
let index: number = this.fieldItems.findIndex((item: any) => Object.is(item.value, field.prop));
if(index < 0) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册