// select选择框绑定change事件 获取id
// @change="showProduct"
showProduct(e) {
var ids = e
window.sceneId = ids // 将局部变量变成全局变量
this.findProductType() // 调用接口查询
},
// input输入框绑定keyup事件 输入完成以后使用回车进行搜索
// @keyup.enter.native="showProductCategory"
showProductCategory() {
this.findProductType() // 调用接口查询
},
// 查询接口
async findProductType() {
const option = {
id: sceneId, // 全局变量
productTypeName: this.selectProductTypeForm.search
}
const res = await findProductType(option)
if (res.code === 200) {
console.log(res, '查询')
}
},
局部变量变成全局变量
var ids = e
window.sceneId = ids
input输入框
@change=“showProductCategory”
change 在输入框失去焦点或用户按下回车时触发
@keyup.enter.native=“showProductCategory”
keyup.enter.native在输入后使用回车时触发