:class="{'current':currentIndex===$index}"
来源:17-8 better-scroll运用(3)

慕仙5575612
2020-02-07
问题1 为啥index要加$ 我是4.1版本的 不加$就不行
问题2 为啥我在这里console currentIndex老是=0?代码如下
created () {
this.classMap = ['decrease', 'discount', 'special', 'invoice', 'guarantee']
this.$http.get('/api/goods').then((response) => {
response = response.body
if (response.errno === ERR_OK) {
this.goods = response.data
this.$nextTick(() => {
this._initScroll()
this._calculateHeight()
console.log(this.currentIndex)
})
写回答
1回答
-
ustbhuangyi
2020-02-07
$index 应该是 vue 1.x 的语法,你可以参考 2.x v-for 指令的语法。
你这个逻辑只会执行一次,执行的时候是什么值就是什么值了。
另外我不太建议你跟着 1 期视频敲代码,1期视频建议是看一遍视频即可,然后跟着二期视频做一遍。042020-02-07
相似问题