question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

$listeners is readonly. $attrs is readonly.

See original GitHub issue

Hello. I have an error when using vue-property-decorator in my additional library. _790

From this stackoverflow answer. Vue is being loaded/packed into the bundle by webpack and also loaded externally (not via webpack)
https://stackoverflow.com/a/50932919/5988531

I do something like this in my main.ts:

import MyIcon from '<my-external-library>/src/components/icon/icon.vue';
Vue.component('my-icon', MyIcon);

Then, I use my-icon in the project and got an error.

Do you have any comments or suggestions for this?

P.S. I think this is because We need to extend Vue class in *.vue file. Can I use property decorators without extending a Vue instance?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jarekcieslakcommented, May 15, 2019

Sure. So by saying that the library is marked as external, you tell webpack/rollup not to bundle it together with the rest of js files, even if the library is referenced from js files.

You push the responsibility of providing this library (eg. vue-property-decorator) to the application consuming your library. I was using rollup in my project. Everything described in more verbose way here: https://rollupjs.org/guide/en#peer-dependencies, and I see that webpack has something similar: https://webpack.js.org/configuration/externals/

0reactions
social-unicommented, Sep 30, 2022

+1

I customized a component and introduced it into the project in the form of link npm, which triggered this error

<template>
  <div>
    <slot></slot>
  </div>
</template>

<script lang="ts">
import {Component, Vue} from 'vue-property-decorator'

@Component
export default class TestDiv extends Vue {

}

</script>

{
  "name": "YComponent",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies": {
    "pinyin-match": "^1.1.8",
    "element-ui": "^2.13.1"
  },
  "devDependencies": {
    "vue-class-component": "^7.2.3",
    "vue-property-decorator": "^9.1.2",
    "ts-node": "^10.7.0",
    "tslib": "^2.4.0",
    "typescript": "4.6.3",
    "vue-template-compiler": "2.7.10"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}
"YComponent": "../YComponent"
Read more comments on GitHub >

github_iconTop Results From Across the Web

"$attrs is readonly","$listeners is readonly","Avoid mutating a ...
I am new to Vue. I am trying to develop a chatting application where friend list will be shown on the left menu...
Read more >
SOLVED: [Vue error] $attrs is readonly / $listeners is ... - GitHub
Hello everyone! I have a problem with bootsrap-vue. I use vue cli 3 and an error appears $attr $listener readonly. Please help ^^ ......
Read more >
[Vue warn]: $attrs is readonly - Get Help
Hi! I get warnings on keypresses, they are: [Vue warn]: $attrs is readonly. [Vue warn]: $listeners is readonly. [Vue warn]: Avoid mutating a ......
Read more >
Vue warning: $attrs is readonly. - Material Design for Bootstrap
I keep getting this error in the console (see video), but only as soon as I work with routes.
Read more >
Vue warn $listeners and $attrs is readonly - Stack Overflow
I am getting a lot of Vue warnings saying $listeners is readonly or $attrs is readonly and related to different Bootstrap items or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found