请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

:class="{'current':currentIndex===$index}"

问题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)
          })

正在回答 回答被采纳积分+3

1回答

ustbhuangyi 2020-02-07 09:57:37

$index 应该是 vue 1.x 的语法,你可以参考 2.x v-for 指令的语法。
你这个逻辑只会执行一次,执行的时候是什么值就是什么值了。
另外我不太建议你跟着 1 期视频敲代码,1期视频建议是看一遍视频即可,然后跟着二期视频做一遍。

0 回复 有任何疑惑可以回复我~
  • 提问者 慕仙5575612 #1
    老师您的二期视频是用跳的 我出了问题都不知道去哪里查,有没有二期每个阶段的代码。 不然您给的是最终代码,最终代码跟二期每个阶段的代码差很多,我根本没法查问题
    回复 有任何疑惑可以回复我~ 2020-02-07 10:21:27
  • 提问者 慕仙5575612 #2
    还有这个是什么语法 'current':currentIndex===$index
    为啥currentIndex===$index就有current
    回复 有任何疑惑可以回复我~ 2020-02-07 10:22:57
  • ustbhuangyi 回复 提问者 慕仙5575612 #3
    那就对比一下 1 期视频的 vue 2.x 的源码:https://github.com/ustbhuangyi/vue-sell/tree/2.0。
    回复 有任何疑惑可以回复我~ 2020-02-07 10:32:27
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信