v-for循环。我将在每个复选框中获得相同的值

时间:2017-06-26 18:05:40

标签: vue.js

我将展示用户最喜欢的音乐流派的循环。但我想从我的Vue实例中的属性中读取它们。这是我的代码:

Traceback (most recent call last):
  File "<pyshell#24>", line 1, in <module>
    driver.find_element_by_xpath("//*[@id='specialty-106']").click()
  File "C:\Python27\lib\site-packages\selenium-2.46.0-py2.7.egg\selenium\webdriver\remote\webelement.py", line 70, in click
    self._execute(Command.CLICK_ELEMENT)
  File "C:\Python27\lib\site-packages\selenium-2.46.0-py2.7.egg\selenium\webdriver\remote\webelement.py", line 404, in _execute
    return self._parent.execute(command, params)
  File "C:\Python27\lib\site-packages\selenium-2.46.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 195, in execute
    self.error_handler.check_response(response)
  File "C:\Python27\lib\site-packages\selenium-2.46.0-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 170, in check_response
    raise exception_class(message, screen, stacktrace)
WebDriverException: Message: unknown error: Element <input type="checkbox" id="specialty-106" name="Specialty[]" value="106"> is not clickable at point (281, 554). Other element would receive the click: <label for="specialty-106"></label>
  (Session info: chrome=58.0.3029.110)
  (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 6.1.7600 x86_64)

但最后我会得到以下图片和复选框的值属性不会改变!为什么我会在每个复选框中获得相同的值?

same values at each checkbox

2 个答案:

答案 0 :(得分:1)

您需要绑定流派变量。

<input type="checkbox" v-model="selectedGenres" :value="genre">

将计算流派而不仅仅是给出字符串类型

答案 1 :(得分:1)

我不确定,但我认为你应该改变你所说的代码:

value="genre"  

并将其更改为:

v-bind:value="genre" or :value="genre"