Heim  >  Fragen und Antworten  >  Hauptteil

Vuejs/Nuxtjs: Wie erstelle ich dynamische V-Modellnamen, ohne v-for zu verwenden?

Ich bin bei Vuejs/Nuxtjs 应用程序中遇到了一个棘手的问题。在应用程序中,我动态创建多个 Nodes 。这些 NodesRadio 按钮 我已为其分配了 v-model。但是,当我更改一个 Vuejs v-model 的值时,会影响所有其他 Node wert.

Ich weiß, dass dieses Problem aufgrund aller Nodes 使用相同的 V-model。我想为我的 Radio 按钮 分配不同的 V-model 但我想在不使用 v-for Fälle auftritt, in denen dies der Fall ist.

Ich habe den Beispielcode in CodeSandbox erstellt

Schritte zur Reproduktion:

  1. wird Identifiers 拖放到画布中。现在将选择 URN.
  2. Fügen Sie nun ein weiteres Identifiers 拖放到画布中。现在第一个 Identifiers 节点:URN 将消失。我无法独立处理每个 Node 值 hinzu.

Das Problem tritt bei Dateien @components/IdentifiersNode.vue und Optionsfeldern auf.

Codebeispiel basierend auf Kissu-Antwort:

<input
    id="identifierTypeURN"
    :data="identifierSyntax"
    value="URN"
    type="radio"
    name="instanceIdentifierURN"
    @input="instanceIdentifiersSyntaxChange('URN')"
>
<label for="identifierTypeURN">URN</label>
<input
    id="identifierTypeWebURI"
    :data="identifierSyntax"
    value="WebURI"
    type="radio"
    name="instanceIdentifierWebURI"
    @input="instanceIdentifiersSyntaxChange('WebURI')"
>
<label for="identifierTypeWebURI">WebURI</label>

Kann sich jemand das ansehen und mir sagen, was ich hier falsch mache: https://codesandbox.io/s/cocky-matan-kvqnu?file=/nuxt.config.js

P粉920199761P粉920199761293 Tage vor492

Antworte allen(1)Ich werde antworten

  • P粉132730839

    P粉1327308392023-12-31 22:10:20

    经过一番努力,终于可以正常工作了。我错误地使用了 Radio 按钮 功能。我把它改成了这样,效果很好:

    
    
    
    
    
    

    Antwort
    0
  • StornierenAntwort