【发布时间】:2016-04-05 11:03:55
【问题描述】:
我正在尝试在 vue 指令中使用 lodash 方法 (_.isEmpty),如下所示:
<div class="post" v-for="post in posts"></div>
...
<div class="comments" v-if="! _.isEmpty(post.comments)">
<div class="comment" v-for="comment in post.comments"></div>
</div>
...
</div>
但出现以下错误:
未捕获的类型错误:无法读取未定义的属性“isEmpty”
vue 似乎在当前作用域内寻找_.isEmpty 方法。在这种情况下我应该如何调用全局函数?
【问题讨论】:
标签: vue.js