Skip to content
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

select option v-for 出错 #1162

Closed
jianweiqin opened this issue Jun 3, 2021 · 1 comment
Closed

select option v-for 出错 #1162

jianweiqin opened this issue Jun 3, 2021 · 1 comment

Comments

@jianweiqin
Copy link

jianweiqin commented Jun 3, 2021

vue 版本:2.6.11

以下代码会出错:

<select v-model="selected">
  <option v-for="option in options" v-bind:value="option.value">
    {{ option.text }}
  </option>
</select>

错误信息:ReferenceError: option is not defined

加一个<template>就可以:

<select v-model="selected">
  <template>
    <option v-for="option in options" v-bind:value="option.value">
      {{ option.text }}
    </option>
  </template>
</select>

但如果把 v-for 写在 <template> 里,也会出错。
是什么问题?

@Justineo
Copy link
Member

Justineo commented Jun 3, 2021

这里是文档翻译项目,请到 vuejs/vue 提交 issue 并提供问题复现,谢谢。

@Justineo Justineo closed this as completed Jun 3, 2021
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

2 participants