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

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函数


利用Table的render实现图片、替换

{

title: ‘学校logo’,

align: ‘center’,

key: ‘logo’,

width: 105,

render: (h, params) => {

return h(‘div’, [

h(‘img’, {

style: ‘width:100%;height:100%;margin:5px’,

attrs: {

src: params.row.logo

}

})

])
}
},

最后

你要问前端开发难不难,我就得说计算机领域里常说的一句话,这句话就是『难的不会,会的不难』,对于不熟悉某领域技术的人来说,因为不了解所以产生神秘感,神秘感就会让人感觉很难,也就是『难的不会』;当学会这项技术之后,知道什么什么技术能做到什么做不到,只是做起来花多少时间的问题而已,没啥难的,所以就是『会的不难』。

我特地针对初学者整理一套前端学习资料

前端路线图

o’,

width: 105,

render: (h, params) => {

return h(‘div’, [

h(‘img’, {

style: ‘width:100%;height:100%;margin:5px’,

attrs: {

src: params.row.logo

}

})

])
}
},

最后

你要问前端开发难不难,我就得说计算机领域里常说的一句话,这句话就是『难的不会,会的不难』,对于不熟悉某领域技术的人来说,因为不了解所以产生神秘感,神秘感就会让人感觉很难,也就是『难的不会』;当学会这项技术之后,知道什么什么技术能做到什么做不到,只是做起来花多少时间的问题而已,没啥难的,所以就是『会的不难』。

我特地针对初学者整理一套前端学习资料

[外链图片转存中…(img-eAZtJNY5-1720090822143)]

vue.js的36个技巧

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值