el-select 远程搜索无限请求?

使用el-select远程搜索,刚进入页面时不停地调搜索接口,请问是参数设置有什么问题吗?我是根据文档来的
image.png
这是搜索的方法
image.png

进入页面之后
image.png

请各位指点!!

阅读 2.6k
3 个回答

remoteMethod方法里面一般加个判断比较好,关键字为空不去处理,也就不请求

remoteMethod(keyword) {
  if(!keyword.trim()) return 
  this.getAreaDetail(keyword)
}

再就是remote-method绑定一个方法名即可不需要调用 :remote-method="remoteMethod"

绑定的时候不需要执行也就是说,直接传入函数即可:

<el-select
  ...
-  :remote-method="remoteMethod(scope.row.nodeName)"
+  :remote-method="remoteMethod"

remote-method绑定的是一个函数句柄,不是执行它也就是要这么写:remote-method="remoteMethod"

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题