Composition-api: [Vue warn]: The setup binding property "xxx" is already declared.

Created on 26 Dec 2019  Â·  6Comments  Â·  Source: vuejs/composition-api

Existing project need to use vue3.0,i add '@vue/composition-api' to my project。
dependencies:

  1. "vue": "2.5.22",
    2."@vue/composition-api": "^0.3.4",
    I run the following code and the console prompts me:
    md5-9b929ad83b3f036e570799f2b9ebada6

1577327135(1)

Most helpful comment

Not sure but this bug still appears when doing test by mocking methods.

handler module:

{
   ...
   ...
   return {
      method1
   }
}
export default handlerFn

vue component:

<template>
  <button @clcik="method1"></button>
</template
const { method1 } = handlerFn()

setup(){
return{
   method1
  }
}

test with mock

const spy1 = jest.spyOn(handler, 'method1')
    const w = mount(LoginComponent, {
       mocks: {
        method1: spy1
      }
    })
  expect(spy1).toBeCalled()

The test passes but the warning never goes away.

[Vue warn]: The setup binding property "method1" is already declared.

tested on
"@vue/composition-api": "0.5.0", "0.6.7" & "1.0.0-beta.11"

All 6 comments

Thanks @jacekkarczmarczyk
@mbbbc open a new issue with a repro if you manage to reproduce it and make sure to use the latest version of Vue as well

open a new issue with a repro if you manage to reproduce it and make sure to use the latest version of Vue as well

if I use mixins to declares a method, then I rewrite this method in my component,and then I get this warning

Not sure but this bug still appears when doing test by mocking methods.

handler module:

{
   ...
   ...
   return {
      method1
   }
}
export default handlerFn

vue component:

<template>
  <button @clcik="method1"></button>
</template
const { method1 } = handlerFn()

setup(){
return{
   method1
  }
}

test with mock

const spy1 = jest.spyOn(handler, 'method1')
    const w = mount(LoginComponent, {
       mocks: {
        method1: spy1
      }
    })
  expect(spy1).toBeCalled()

The test passes but the warning never goes away.

[Vue warn]: The setup binding property "method1" is already declared.

tested on
"@vue/composition-api": "0.5.0", "0.6.7" & "1.0.0-beta.11"

It happened if I register VueCompositionAPI twice like this:

import Vue from 'vue'
import VueCompositionAPI from '@vue/composition-api'

Vue.use(VueCompositionAPI)

const localVue = createLocalVue()
localVue.use(VueCompositionAPI )

const wrapper = mount(Component, {
  localVue
})

Not sure but this bug still appears when doing test by mocking methods.

handler module:

{
   ...
   ...
   return {
      method1
   }
}
export default handlerFn

vue component:

<template>
  <button @clcik="method1"></button>
</template
const { method1 } = handlerFn()

setup(){
return{
   method1
  }
}

test with mock

const spy1 = jest.spyOn(handler, 'method1')
    const w = mount(LoginComponent, {
       mocks: {
        method1: spy1
      }
    })
  expect(spy1).toBeCalled()

The test passes but the warning never goes away.

[Vue warn]: The setup binding property "method1" is already declared.

tested on
"@vue/composition-api": "0.5.0", "0.6.7" & "1.0.0-beta.11"

It happened if I register VueCompositionAPI twice like this:

import Vue from 'vue'
import VueCompositionAPI from '@vue/composition-api'

Vue.use(VueCompositionAPI)

const localVue = createLocalVue()
localVue.use(VueCompositionAPI )

const wrapper = mount(Component, {
  localVue
})

Not sure but this bug still appears when doing test by mocking methods.
handler module:

{
   ...
   ...
   return {
      method1
   }
}
export default handlerFn

vue component:

<template>
  <button @clcik="method1"></button>
</template
const { method1 } = handlerFn()

setup(){
return{
   method1
  }
}

test with mock

const spy1 = jest.spyOn(handler, 'method1')
    const w = mount(LoginComponent, {
       mocks: {
        method1: spy1
      }
    })
  expect(spy1).toBeCalled()

The test passes but the warning never goes away.

[Vue warn]: The setup binding property "method1" is already declared.

tested on
"@vue/composition-api": "0.5.0", "0.6.7" & "1.0.0-beta.11"

@webrsb I only have localVue.use(VueCompositionAPI)

Was this page helpful?
0 / 5 - 0 ratings