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.

Issue with Dynamic Arguments

See original GitHub issue

Hi All,

I tried the examples in https://vuejs.org/v2/guide/syntax.html#Dynamic-Arguments but I was not successful as I always get the below warnings in the console.

[Vue warn]: Property or method “attribname” is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.

My HTML:

<!-- Dynamic Arguments-->
<h4 class="comment">Dynamic Arguments</h4>
<a v-bind:[attribName]="urlNamecheap">Visit Namecheap.com</a>
<button v-on:[eventName]="doSomething">Click me</button>

My Script:

<script>
      var vm = new Vue({
        el: '#app',
        data: {
          msg: 'Hello Vue!',
          rawHtml: '<span style="color:  red">This should be red.</span>',
          dynamicId: 'mainDiv',
          isButtonDisabled: true,
          number: 1000,
          ok: true,
          message: 'I love my Razan',
          id: 'Rzn248',
          seen: true,
          url: 'https://www.google.com',
          urlNamecheap: 'https://www.namecheap.com',
          attribName: 'href',
          eventName: 'click'

        },
        methods: {
          doSomething: function() {
            console.log('I just got fired up, who was it?');
          }
        }
      });
    </script>

Am I doing something wrong or is there indeed an issue?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
LinusBorgcommented, May 10, 2019

Hm, this might indeed be an iusse in a specific use case that you came across, as it seems.

Let me explain:

The immediate reason that you are seeing an error is that you are defining your template directly in an HTML page, so the browser interprets the HTML before Vue does. And the browser turns all attributes to lowercase HTML is case-insensitive.

So to Vue, your template looks like this:

<a v-bind:[attribname]="urlNamecheap">Visit Namecheap.com</a>

…while your property in the component is called attribName

Usually, in other cases such as props, Vue can deal with that by converting kebap-case attributes into camelCase properties:

<a v-bind:prop-name="urlNamecheap">Visit Namecheap.com</a>
Vue.component({
  props: ['propName'] // Vue realizes hat in the template, we call it `prop-name`
})

This is documented in our docs somewhere, but I can’t point you to it from the top of my head.

This doesn’t seem to happen for dynamic attributes though 😕

We should probably transfer this issue to the core repository.

/cc @chrisvfritz ?

0reactions
BinMakkicommented, May 11, 2019

Hi @sdras , Yes it does shed light, and I also agree with you that it should be brought forward in a clearer manner.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript issue with dynamic types of argument
I'm trying to make getter and setter in Typescript and facing issues with dynamic types of arguments.
Read more >
Dynamic arguments and type check · Issue #4374 - GitHub
When I change the selection of the field_dropdown, I will change all of the rest arguments of the block, includes number and type...
Read more >
DynamicArgumentDialog - Accept Dynamic Arguments - Help
Hello, I am creating a custom activity in which I need to leverage the DynamicArgumentDialog class. This is the one one that lets...
Read more >
Fixing common type problems - Dart programming language
When a generic subclass neglects to specify a type argument, the analyzer infers the dynamic type. This is likely to cause errors. You...
Read more >
Dynamic Argument, Brief: Lamm, Robert, Everett, Justin
This cutting-edge rhetoric combines a practical, process-oriented approach to argumentative writing with dynamic visuals and fresh, contemporary content.
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