Skip to content

error for resolving repeat component in strict mode #1191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TerenceZ opened this issue Aug 21, 2015 · 0 comments
Closed

error for resolving repeat component in strict mode #1191

TerenceZ opened this issue Aug 21, 2015 · 0 comments

Comments

@TerenceZ
Copy link

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant