开发者问题收集

我如何清除此错误,指出无效的点击事件

2022-12-30
184

Editorial.vue;

    <templates>
      <div class="col offset-2">
           <router-link to="editorial">
              <base-button type="info" @click="saveUserData">Save</base-button>
           </router-link>
       </div>
    </templates>     


   data() {
        return {
        userdetails: {
        logoURL: null
               }
            }
           },

   methods: {
                   
      saveUserData: function () {
         let formData = new FormData()
        formData.append('logoURL', this.userdetails.logoURL)
     this.api.uploadFile('editorial/'+store.state.journalId+'/editorialimage'
       ,formData'journals/v1/').then((res) => {
        this.userdetails.journalId = store.state.journalId
        this.userdetails.imageId = res.data.status
        this.createNewMember()
         }, (err) => {
       console.log(err)
         })
          },








    When I click save button I'm getting the below error

    "Invalid handler for event "click": got undefined

    found in

   ---> <BaseButton> at src/components/BaseButton.vue
    <RouterLink>
      <Card> at src/components/Cards/Card.vue
       <Anonymous>
         <ZoomCenterTransition>
           <DashboardLayout> at src/pages/Layout/DashboardLayout.vue
             <App> at src/App.vue
               <Root>"

    "I'm getting the above error I don't the solution, the function name also mentioned correctly but still I'm getting the same error. Searched some of the solution but nothing worked. The function posting some data to the server but while clicking the button getting the error". Tried lots of ways to solve this but its all failed. 

“我遇到了上述错误,我不知道解决方案,函数名称也正确提及,但我仍然收到相同的错误。搜索了一些解决方案,但都不起作用。该函数将一些数据发布到服务器,但在单击按钮时出现错误”。尝试了很多方法来解决这个问题,但都失败了。

1个回答

那个 base-button 是什么?如果是自定义组件,您需要从组件中定义 emit 事件,以便父组件可以捕获该事件并触发 saveUserData 函数

您可能需要提供有关自定义组件的一些信息

这里有一些关于如何使用 emit 的详细信息 https://vuejs.org/guide/components/events.html

Muhamad Jamil
2022-12-30