uniapp项目vue3 ts编译报错,绑定元素“item”隐式具有“any”类型,怎么处理?

作者站长头像
站长
· 阅读数 9

编译时报错不明白问题出在哪里绑定元素“item”隐式具有“any”类型uniapp项目vue3 ts编译报错,绑定元素“item”隐式具有“any”类型,怎么处理?uniapp项目vue3 ts编译报错,绑定元素“item”隐式具有“any”类型,怎么处理?

<template>
    <view class="content">
        <swiper
            v-if="swiperList"
            :indicator-dots="true"
            :autoplay="true"
            :interval="3000"
            :duration="1000"
            :circular="true">
            <swiper-item
                v-for="item in swiperList"
                :key="item.goods_id">
                <image
                    mode="aspectFill"
                    :src="{{item.image_src}}"></image>
            </swiper-item>
        </swiper>
    </view>
</template>

<script setup lang="ts">
import { onLoad } from "@dcloudio/uni-app";
import { ref } from "vue";
const swiperList = ref([{ image_src: "", goods_id: "1" }]);
onLoad(async () => {
    const res = await uni.request({ url: "https://www.uinav.com/api/public/v1/home/swiperdata" });
    swiperList.value = res.data.message;
    console.log(swiperList.value);
});
</script>

<style>
</style>

源码地址https://gitee.com/sachin-ye/u...

是因为之前小程序用:src="{{item.image_src}}"现在是vue应该直接:src="item.image_src"

回复
1个回答
avatar
test
2024-07-11

因为之前学小程序所以写的是 :src="{{item.image_src}}"uniapp 用的是 vue 所以应该修改为 :src="item.image_src"

回复
likes
适合作为回答的
  • 经过验证的有效解决办法
  • 自己的经验指引,对解决问题有帮助
  • 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
  • 询问内容细节或回复楼层
  • 与题目无关的内容
  • “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容