: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期视频建议是看一遍视频即可,然后跟着二期视频做一遍。

0
4
ustbhuangyi
回复
慕仙5575612
参考 https://cn.vuejs.org/v2/guide/class-and-style.html 这个文档。
2020-02-07
共4条回复

Vue.js2.5+cube-ui重构饿了么App(经典再升级)

掌握Vue1.0到2.0再到2.5最全版本应用与迭代,打造极致流畅的WebApp

9868 学习 · 4162 问题

查看课程