代码之家  ›  专栏  ›  技术社区  ›  sungyong

VueJS:将v-for的实例传递到样式时,ReferenceError“未定义”

  •  0
  • sungyong  · 技术社区  · 7 年前

    我很难实现类。
    我的 <a> 有两个css类- normal', '

    下面是我的html代码。

    <a href="#none" v-for="busstop in busstops"     
       id="busstop.id"
       :class="['marker', isBusStopFail(busstop) ? 'fault': 'normal']"                        
       onclick="detailsOpen(this);"></a>
    

    data: {
       busstops: []
       ....
    methods: {
       isBusStopFail: function(busstop) {
          let failDevice = bussstop.fail;
          if (failDevice.led || failDevice.usb || failDevice.bell || failDevice.gw) {
                 return false;
          } else {
                 return true;
          }
      },
      ...
    

    我的目标是将实例传递给方法。

    [Vue warn]:呈现中出错:“ReferenceError:未定义bussstop”

    1 回复  |  直到 7 年前
        1
  •  1
  •   F.Igor    7 年前

    这只是一个打字错误。请检查线路

    let failDevice = bussstop.fail;
    

    换成

    let failDevice = busstop.fail;
    
    推荐文章