【发布时间】:2022-01-04 02:05:34
【问题描述】:
我有一系列年份 [2016,2017,2018,2019,2020,2021]
我用这个函数用computed得到当年的索引
getSelectedYearIndex(){
return this.getYears.length - 1
},
这个函数返回 5
然后用select 选择跨过新的一年,并在methods 的这个函数中用$emit 接收新值
onSelect({ selectedIndex }) {
this.getSelectedYearIndex = selectedIndex
}
什么都没有发生。
是否有可能改变计算属性?
【问题讨论】:
-
这意味着它不应该首先被计算。但这也取决于如果数组发生变化它应该如何表现。
-
这是computed properties 的文档。请注意此声明... “默认情况下,计算属性仅限 getter”
标签: javascript vue.js vuejs2