Skip to content

[Vue warn]: $attrs is readonly.[Vue warn]: $listeners is readonly. #6698

@hxfdarling

Description

@hxfdarling

Version

2.4.4

Reproduction link

https://github.com/hxfdarling/vue-demo

Steps to reproduce

  1. vue引入后作为window下全局变量使用,作为为单一文件引入(如果在同一文件下不会出现该错误)
  2. 通过v-model绑定一个自定义checkbox组建
  3. 直接在root元素使用该组建会出现[Vue warn]: $attrs is readonly.[Vue warn]: $listeners is readonly.警告
  4. 如果通过其他组建间接使用,不会出现该问题
  5. 具体代码如https://github.com/hxfdarling/vue-demo 演示所示,点击第一个按钮会报错,点击第二个按钮正常

What is expected?

不要报警告错误

What is actually happening?

2017-09-27_14-49-39

vue.esm.js:476 [Vue warn]: $attrs is readonly.

found in

---> <Checkbox> at E:\github\vue-webpack-test\src\components\checkbox.vue
       <Root>
warn @ vue.esm.js:476
(anonymous) @ vue.esm.js:4150
reactiveSetter @ vue.esm.js:989
updateChildComponent @ vue.js:2625
prepatch @ vue.js:3572
patchVnode @ vue.js:5497
updateChildren @ vue.js:5405
patchVnode @ vue.js:5508
patch @ vue.js:5657
Vue._update @ vue.js:2464
updateComponent @ vue.js:2578
get @ vue.js:2919
run @ vue.js:2996
flushSchedulerQueue @ vue.js:2764
(anonymous) @ vue.js:704
nextTickHandler @ vue.js:651
Promise resolved (async)
timerFunc @ vue.js:666
queueNextTick @ vue.js:714
queueWatcher @ vue.js:2851
update @ vue.js:2986
notify @ vue.js:781
reactiveSetter @ vue.js:1003
proxySetter @ vue.js:3111
callback @ VM10180:2
invoker @ vue.esm.js:1821
Vue.$emit @ vue.esm.js:2331
change @ checkbox.vue:49
boundFn @ vue.esm.js:179
invoker @ vue.esm.js:1821
vue.esm.js:476 [Vue warn]: $listeners is readonly.

found in

---> <Checkbox> at E:\github\vue-webpack-test\src\components\checkbox.vue
       <Root>
warn @ vue.esm.js:476
(anonymous) @ vue.esm.js:4153
reactiveSetter @ vue.esm.js:989
updateChildComponent @ vue.js:2626
prepatch @ vue.js:3572
patchVnode @ vue.js:5497
updateChildren @ vue.js:5405
patchVnode @ vue.js:5508
patch @ vue.js:5657
Vue._update @ vue.js:2464
updateComponent @ vue.js:2578
get @ vue.js:2919
run @ vue.js:2996
flushSchedulerQueue @ vue.js:2764
(anonymous) @ vue.js:704
nextTickHandler @ vue.js:651
Promise resolved (async)
timerFunc @ vue.js:666
queueNextTick @ vue.js:714
queueWatcher @ vue.js:2851
update @ vue.js:2986
notify @ vue.js:781
reactiveSetter @ vue.js:1003
proxySetter @ vue.js:3111
callback @ VM10180:2
invoker @ vue.esm.js:1821
Vue.$emit @ vue.esm.js:2331
change @ checkbox.vue:49
boundFn @ vue.esm.js:179
invoker @ vue.esm.js:1821
vue.esm.js:476 [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "value"

found in

---> <Checkbox> at E:\github\vue-webpack-test\src\components\checkbox.vue
       <Root>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions