账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    vue2.x filters中如何调取computed中的属性,另外filters中的方法添加多个参数template里调用报错
    70
    0

    以下是demo

    <script>
      export default {
        props: ['userList', 'sessionIndex', 'session', 'search'],
        filters: {
          selection (list, sear) {
            return list.filter(item => item.name.indexOf(sear) > -1)
          }
        }
      }
    </script>
    
    <template>
        <div class="m-list">
            <ul>
                <li v-for="item in userList | selection(search)" :class="{ active: session.userId === item.id }">
                    <img class="avatar" width="30" height="30" :alt="item.name" :src="item.img">
                    <p class="name">{{item.name}}</p>
                </li>
            </ul>
        </div>
    </template>
    

    console报错信息如下

    Vue warn: Property or method "selection" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
    
    Error in render: "TypeError: _vm.selection is not a function"
    
    TypeError: _vm.selection is not a function
    0
    打赏
    收藏
    点击回答
    您的回答被采纳后将获得:提问者悬赏的 10 元积分
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部