Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/412.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么我的函数是无止境循环?怎么能ı;下班后停车_Javascript_Vuejs2 - Fatal编程技术网

Javascript 为什么我的函数是无止境循环?怎么能ı;下班后停车

Javascript 为什么我的函数是无止境循环?怎么能ı;下班后停车,javascript,vuejs2,Javascript,Vuejs2,我的功能在工作后从未停止过 我试着抓住,但没有 这是我的vue代码: <template v-for="(event,index) in eventsMap[date]"> <v-menu :key="index" full-width offset-x> <template v-slot:activator="{ on }"> 这是我的javascript代码: <v-flex> <template v-for="(event

我的功能在工作后从未停止过

我试着抓住,但没有

这是我的vue代码:

<template v-for="(event,index) in eventsMap[date]">

<v-menu :key="index" full-width offset-x>

<template v-slot:activator="{ on }">

这是我的javascript代码:

<v-flex>
  <template v-for="(event,index) in eventsMap[date]">
    <v-menu :key="index" full-width offset-x>
      <template v-slot:activator="{ on }">
        <div v-ripple v-bind:style="Styles3" v-on="on">{{ findID(event.UserNo) }}</div>
      </template>
      <template v-for="(event,index) in eventsMap[date]">
        <v-menu :key="index" full-width offset-x>
          <template v-slot:activator="{ on }">

function findID(val) {
  try {
    var params = {
      UserID: val
    }

    this.$http.post(auth.API_URL + 'api/Problems/User', params, {
      headers: {
        'Authorization': 'Bearer ' + auth.getAuthHeader()
      }
    }).then((response) => {
      this.userList = response.body
    }, (response) => {
      if (response.Status === true) {
        this.text1 = response.body.ResponseMessage
        this.snackbar = true
      } else {
        this.text1 = response.statusText
        this.snackbar = true
      }
    })

    return this.userList
  } catch (e) {
    alert(e);
  }
}


{{findID(event.UserNo)}
函数findID(val){
试一试{
变量参数={
用户ID:val
}
这是.$http.post(auth.API_URL+'API/Problems/User',params{
标题:{
“授权”:“持有者”+auth.getAuthHeader()
}
})。然后((响应)=>{
this.userList=response.body
},(回应)=>{
如果(response.Status==true){
this.text1=response.body.ResponseMessage
this.snackbar=true
}否则{
this.text1=response.statusText
this.snackbar=true
}
})
返回这个.userList
}捕获(e){
警报(e);
}
}
谢谢你的帮助


我没有错误消息,但此函数从未停止。

名为
idbul
的函数的逻辑是什么样子的?这与
findID(val)
相同吗?如果是这样,则每次函数调用都可能导致模板更新,并且每次模板更新都可能调用函数,从而调用循环。是的,我如何使用此结构?您可能只想访问现有变量,而不是从模板(
{{findID(event.UserNo)}}
)调用findID(请尝试类似于
{{myVar}}
的内容)。目前我还不清楚代码的意图。如果您试图显示此.userList(可能是用户列表?),则可能需要对其执行v-for操作。在任何情况下,您都需要findID()在特定条件下调用,而不是在模板中,每次更新模板时都会调用它。相反,请尝试在定义后立即调用它,然后从那里开始。