00xjacky
00xjacky
  • 发布:2024-05-15 03:57
  • 更新:2024-05-15 22:58
  • 阅读:59

语法错误: Unexpected token, expected "," (1:296)

分类:uni-app

报错如下

Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/templateLoader.js):  
语法错误: Unexpected token, expected "," (1:296)  
at pages\cate\cate.vue:1

vue语法代码如下,为什么会报错?不应该这样写法?还是说是bug?

<template>  
  <view>  
    <!-- 分类页面 -->  
    <view class="classify-view-container">  
      <!-- 左侧 -->  
      <scroll-view  
        class="letft-scroll-view"  
        scroll-y="true"  
        :style="{ height: letftHeight + 'px' }"  
      >  
        <view  
          v-for="(item, index) in categoriesList"  
          :key="index"  
          @click="activationitem(index)"  
          :class='{ letft-scroll-view-item Activation===index ? Active : "" }'  //就是这行报错,哪里不对吗?不应该这样写吗?  
        >  
          {{ item.cat_name }}  
        </view>  
      </scroll-view>  
      <!-- 右侧 -->  
      <view  
        class="right-scroll-view"  
        scroll-y="true"  
        :style="{ height: letftHeight + 'px' }"  
      >  
        <scroll-view>2222</scroll-view>  
        <scroll-view>2222</scroll-view>  
        <scroll-view>2222</scroll-view>  
        <scroll-view>2222</scroll-view>  
        <scroll-view>2222</scroll-view>  
      </view>  
    </view>  
  </view>  
</template>  

<script>  
export default {  
  data() {  
    return {  
      // 商品分类数据  
      categoriesList: [],  
      // 激活选中项  
      Activation: 0,  
      // 动态滚动高度  
      letftHeight: 0,  
      isActive: 0,  
    };  
  },  
  onLoad() {  
    this.getCategories();  
    this.getHeight();  
  },  
  methods: {  
    async getHeight() {  
      // 动态获取可使用窗口高度  
      const windowInfo = await uni.getWindowInfo();  
      console.log(windowInfo.windowHeight);  
      this.letftHeight = windowInfo.windowHeight;  
    },  
    async getCategories() {  
      const { data: res } = await uni.$http.get(`categories`);  
      if (res.meta.status == 200) {  
        this.categoriesList = res.message;  
        console.log(res);  
      } else {  
        uni.$showMessage('数据请求失败', 5000, 'error');  
      }  
    },  
    activationitem(index) {  
      this.Activation = index;  
      console.log(this.Activation);  
    },  
  },  
};  
</script>  

<style lang="scss">  
.classify-view-container {  
  display: flex;  

  .letft-scroll-view {  
    width: 115px;  

    .letft-scroll-view-item {  
      background-color: #f7f7f7f7;  
      text-align: center;  
      line-height: 60px;  
      font-weight: 700;  

      & .Active {  
        background-color: pink;  
      }  

      // .title-text-item {  
      //   background-color: red;  
      // }  
    }  
  }  

  .right-scroll-view {  
    flex: 1;  
    // background-color: red;  
  }  
}  
</style>  
2024-05-15 03:57 负责人:无 分享
已邀请:
00xjacky

00xjacky (作者)

问题已经解决:是写法错误的问题,后面把类写法改成如下就好了,我也懒得删除贴子了,就当做个记录标记下

 :class="{  'letft-scroll-view-item': true, 'Activation': index === Active, }"
00xjacky

00xjacky (作者)

问题已经解决:是写法错误的问题,后面把类写法改成如下就好了,我也懒得删除贴子了,就当做个记录标记下,该说不说hbuilderx为什么不会提示语法错误尼?一直提示的是”,“符号问题,这是不是也算一种bug?

 :class="{  'letft-scroll-view-item': true, 'Activation': index === Active, }"
  • 喜欢技术的前端

    害,这不是bug

    2024-05-16 00:03

  • 00xjacky (作者)

    回复 喜欢技术的前端: 这个提示是错误的提示不算一种bug吗?那应该算什么?还是说目前无法做点检测语法错误的问题尼?

    2024-05-18 04:32

要回复问题请先登录注册