【发布时间】:2017-11-12 18:30:03
【问题描述】:
我目前遇到了渲染期间未引用我的导入函数的问题。这段代码更容易解释:
<template>
<div v-for="(addOn, index) in JSON.parse(this.restaurants[0].categories[categoryId].addons)">
<label>
<span>{{ addOn.name }} (+ ${{ addZeroes(addOn.price) }})</span>
</label>
</div>
</template>
<script>
import { addZeroes } from "../../../js/helpers";
export default {
data() {
return {
// populated via AJAX
restaurants: [
{
categories: []
}
],
}
},
}
</script>
<style>
</style>
错误是:
[Vue warn]: Property or method "addZeroes" 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.
在 Vue 模板中调用辅助函数的正确方法是什么?
感谢任何提示!
【问题讨论】:
标签: javascript vue.js