iview踩坑记录(使用iview组件你不得不看的坑点和妙用指南!)

利用Modal的on-visible-change事件使用一个模态框实现增加和修改

// 利用modal_show实现模态框的显示和关闭

<Modal

v-model=“modal_show”

title=“csdn增改”

width=“800”

@on-visible-change=“modalShow”

modalShow (status) {

console.log(status)

if (!status) {

// clearForm为清空模态框输入数据的函数,免得下次点开数据混淆

this.clearForm()

// editStatus判断是否为搜索状态,可以帮助增加和修改不同接口的调用

this.editStatus = false

// 清空一些无法通过清空数据清空的输入框

this.$refs.select.clearSingleSelect()

}

},

补充:

假如同时使用Table组件实现修改功能,修改是数据最好使用深拷贝

{

title: ‘操作’,

align: ‘center’,

key: ‘action’,

width: 125,

minWidth: 125,

render: (h, params) => {

return h(‘div’, [

h(

‘Button’,

{

props: {

type: ‘primary’,

size: ‘small’

},

style: ‘margin-right:5px;’,

on: {

click: () => {

this.newsForm = JSON.parse(JSON.stringify(params.row))

this.add_show = true

this.editStatus = true

this.index = params.row.id

console.log(this.newsForm)

}

}

},

‘修改’

)])

}

}

两个输入框绑定


利用select的label-in-value实现两个输入框的绑定

<Select

v-model=“index”

placeholder=“请选择学校”

filterable

label-in-value

@on-change=“match1”

v-for=“item in universityList”

:label=“item.universityname”

:value=“item.id”

:key=“item.id”

match1 (item) {

if (item) {

this.newsForm.universityid = item.value

this.newsForm.universityname = item.label

}

}

补充:

假如只是实现增加,而无需实现修改,则不需要使用v-model

v-model此处的作用在于修改时将此选项框的选项赋值

select远程搜索


利用select的远程搜索实现输入

// 主要通过:remote-method实现远程搜索

<Select

ref=“select”

v-model=“name”

filterable

clearable

remote

:remote-method=“remoteMethod1”

:loading=“select_loading”

@on-clear=“clear”

v-for=“option in options”

:value=“option.name”

:key=“option.id”

{{ option.name }}</Option

clear () {

this.name = ‘’

this.options = []

},

remoteMethod1 (query) {

if (query !== ‘’) {

this.select_loading = true

searchList(1, 10, query).then(res => {

this.select_loading = false

this.options = res.data.data.data

console.log(res.data.data)

})

} else {

this.options = []

}

}

远程搜索结合两个输入框绑定


select的远程搜索结合实现两个输入框的绑定以及增改

// 主要通过:remote-method实现远程搜索

<Select

ref=“select”

v-model=“index”

filterable

clearable

remote

:remote-method=“remoteMethod1”

:loading=“select_loading”

@on-change=“match1”

@on-clear=“clear”

v-for=“option in options”

:value=“option.companyName”

:key=“option.id”

{{ option.companyName }}</Option

match1 (item) {

console.log(item)

if (item) {

this.newsForm.companyName = item

console.log(item)

if (item !== ‘’) {

searchCompanyList(1, 1, item).then(res => {

this.newsForm.jobCompanyId = res.data.data.data[0].id

})

}

}

},

clear () {

this.newsForm.jobCompanyId = ‘’

this.options = []

},

remoteMethod1 (query) {

if (query !== ‘’) {

this.select_loading = true

searchCompanyList(1, 10, query).then(res => {

this.select_loading = false

this.options = res.data.data.data

console.log(res.data.data)

})

} else {

this.options = []

}

}

// 修改按钮的render函数

render: (h, params) => {

return h(‘div’, [

h(

‘Button’,

{

props: {

type: ‘primary’,

size: ‘small’

},

style: ‘margin-right:5px;’,

on: {

click: () => {

this.newsForm = JSON.parse(JSON.stringify(params.row))

this.add_show = true

this.editStatus = true

this.index = params.row.companyName

console.log(this.newsForm)

}

}

},

‘修改’

)])}

Table render函数

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:前端)

最后

给大家分享一些关于HTML的面试题,有需要的朋友可以戳这里获取,先到先得哦。


888006985)]

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!

[外链图片转存中…(img-lVxTFfCm-1712888006985)]

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:前端)

最后

给大家分享一些关于HTML的面试题,有需要的朋友可以戳这里获取,先到先得哦。

[外链图片转存中…(img-J00l2Wt1-1712888006985)]
[外链图片转存中…(img-y0zbQdN2-1712888006986)]

  • 12
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值