Skip to content

error for resolving repeat component in strict mode #1191

@TerenceZ

Description

@TerenceZ

When in strict asset resolve mode, I have no idea how to repeat component. For example as followed, the console will report that the inner component cannot be resolved.

<outer>
    <template v-repeat="item in data">
        <inner prop={{item.prop}}>{{item.value}}</inner>
    </template>
</outer>

Because when resolving the inner, the resolveAsset is checking the options._parent, not the _context...the modified code is something like:

  // for util/options/resolveAsset
  while (!asset && (!config.strict || options._repeat)) {
    if (options._repeat) {
      if (!options._context) {
        break
      }
      options = options._context.$options
    } else {
      if (!options._parent) {
        break
      }
      options = options._parent.$options
    }
    assets = options[type]
    asset = assets[id] || assets[camelizedId] || assets[pascalizedId]
  }

Of course, we can try another approach if only one component and no needs to pass repeated data to component, but the ability to repeat block will be lost. For example

<outer>
    <inner v-repeat="item in data">{{item}}</inner>
</outer>

However, the code above can work without any errors, but the result is wrong...the {{item}} will always be empty (undefined)... Because the {{item}} is linked within the _context, even if the item is set into the inner instance...

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