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.

Error using multiple dynamic slot names (Invalid dynamic argument expression)

See original GitHub issue

Version

2.6.10

Reproduction link

https://github.com/tbutcaru/v-issue-multiple-dynamic-slot-names

Steps to reproduce

  1. Clone this repo: https://github.com/tbutcaru/v-issue-multiple-dynamic-slot-names
  2. Run: npm install
  3. Run: npm run serve

What is expected?

Multiple dynamic slot names should work as expected.

What is actually happening?

The following error is thrown:

Invalid dynamic argument expression: attribute names cannot contain spaces, quotes, <, >, / or =.#[headerslot]>Header slot</template>
    Default slot
    <template #[footerslot]

If one of the dynamic slot names is made static (doesn’t matter which), the application is working.

My investigation
  • file: node_modules/vue-template-compiler/build.js
  • line: 2563 (inside attrs.forEach(function (attr) {) added the following warn:
warn$1('--------------->> ' +  attr.name);
Investigation results:
  1. In the working scenario with only one dynamic slot name: the value of that dynamic slot name is #[headerslot]
  2. In the error scenario with two dynamic slot names: the value of the first dynamic slot name is
#[headerslot]>Header slot</template>
    Default slot
    <template #[footerslot]

So, it looks like the compiler doesn’t know how to extract just the attribute when there are multiple dynamic slot names.

Issue Analytics

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

github_iconTop GitHub Comments

6reactions
davis90commented, Jan 22, 2020

After many tries, I found a way to make multi dynamic slots work. When i add keys to root element of the dynamics slot templates, it fall in work:

this doesn’t work: reproduce here

   <template #[slot1]>
       <p>slot test</p>
   </template>
   <template #[slot2]>
       <p>slot test2</p>
    </template>

// got "Invalid dynamic argument expression: attribute names cannot contain spaces, quotes, <, >, / or ="

this work: reproduce here

   <template #[slot1]>
       <p key="1">slot test</p>
   </template>
   <template #[slot2]>
       <p key="2">slot test2</p>
    </template>

// work fine

Why i need to add keys to make it work? I missed something.

3reactions
016commented, Apr 1, 2021

Hey all, I am using vue 2.6.10, I got same problem, after google something I found this way to fix it.

  <template v-slot:[`content_`+ValueA]="" >
    12345
  </template>
  <template v-slot:[`content_`+ValueB]>
    12345+101
  </template>

the main idea is add ‘=“”’ after [], remember only last one can keep without =“”, for short just add =“” for all v-slot

good luck for everyone.

btw VUE is good.

a online demo based on @Justineo demo code

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple dynamic named slots - Get Help
I'm having some issues using multiple dynamic slots. ... Errors compiling template: Invalid dynamic argument expression: attribute names ...
Read more >
Vue and Bootstrap Vue - dynamically use slots
Because Vue supports Dynamic Slot Names, you can use variables to set the slot names using the v-bind:[attributeName]="value" syntax.
Read more >
Tips to Supercharge Your Slots (Named, Scoped, and ...
If one slot is great, then multiple slots are better, right? With named slots we can create multiple slots in a component, and...
Read more >
Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >
Phoenix.Component — Phoenix LiveView v0.18.3
For dynamic values, you can interpolate Elixir expressions into a function component: <.greet name={@user.name} />. Function components can also accept ...
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