- 数组遍历渲染后出现警告,为什么?
我把数据遍历渲染后,出现警告 [图片] <template> <view class="selectBox"> <block wx:for="{{selectEleList}}" wx:key="{{item.id}}"> <view class="selectEle" bindtap="selectEleClick" data-id="{{item.id}}" data-name="{{item.name}}"> <view class="selectImg"> <image wx:if="{{item}}" src="{{item.img}}"></image> </view> <view class="selectText">{{item.name}}</view> </view> </block> </view> </template> 求大佬们指点,谢谢大佬们。
2020-07-16 - 点击轮播图跳转详情页并且传个id到详情页报错,求大佬指导?
[图片] 下面是结构目录: [图片] 通过点击banner/index.mpx里的轮播图图片跳转详情页并且传一个id过去在详情页显示 app.mpx <script name='json'> module.exports = { "packages": [ "./components/banner-detail/app.mpx?resolve" ] } </script> banner/index.mpx <template> <view class="page-body"> <view class="swiper"> <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" current="{{current}}" circular="{{circular}}" bindchange="swiperChange"> <block wx:for="{{bannerImage}}" wx:key="index" data-index={{index}}> <navigator url="{{item.url}}" open-type="navigate"> <swiper-item bindtap="imgClick" data-url="{{item.url}}" data-id="{{item.id}}"> <image class="{{item.title}}" wx:if='{{item}}' src="{{item.image}}"></image> </swiper-item> </navigator> </block> </swiper> </view> </view> </template> <style> </style> <script> import { createComponent } from '@mpxjs/core' import banner1 from '../../../img/banner1.png' import banner2 from '../../../img/banner2.png' import banner3 from '../../../img/banner3.png' createComponent({ data: { bannerImage: [ { "id": 1, "image": banner1, "title": "banner1", "url": "https://www.baidu.com/" }, { "id": 2, "image": banner2, "title": "banner2", "url": "https://fanyi.baidu.com/" }, { "id": 3, "image": banner3, "title": "banner3", "url": "https://www.jianshu.com/" } ], indicatorDots: true, vertical: false, autoplay: true, interval: 2000, duration: 500, circular: true, current: 0 }, methods: { swiperChange: function (event) { let current = event.detail.current; this.setData({ current }) }, imgClick: function (e) { console.log(121212, this.data.current); console.log('跳转详情', e.currentTarget.dataset) wx.navigateTo({ //在这里跳转详情页,并且传给详情页一个id url: '../banner-detail/pages/index.mpx?id=' + e.currentTarget.dataset.id }) } } }) </script> <script name="json"> module.exports = { 'component': true } </script> 现在一点击轮播图上的图片就出现报错,每一张都是,都无法跳转更不用说是传参了,求大佬指教,在线急!!!!! [图片]
2020-07-14 - 用数据渲染本地图片轮播图报错为什么?
这个问题真的是恶心到我了,分开一个个的写没事,以数据渲染就出现报错,大佬们帮帮忙,万分感谢。 [图片] VM453:1 Failed to load local image resource /img/home.png the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) 代码: <template> <view class="page-body"> <view class="swiper"> <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}"> <block wx:for="{{bannerImage}}" wx:key="key"> <swiper-item data-url="{{item.url}}"> <image class="{{item.title}}" wx:if='{{item}}' src="{{item.image}}"></image> </swiper-item> </block> </swiper> </view> </view> </template> <style> </style> <script> import { createComponent } from '@mpxjs/core' createComponent({ data: { bannerImage: [ { "id": 1, "image": "/../../../img/home.png", "title": "banner1", "url": "https://www.baidu.com/" }, { "id": 2, "image": "/../../../img/order.png", "title": "banner2", "url": "https://fanyi.baidu.com/" }, { "id": 3, "image": "/../../../img/user.png", "title": "banner3", "url": "https://www.jianshu.com/" } ], indicatorDots: true, vertical: false, autoplay: true, interval: 2000, duration: 500 }, computed: { } }) </script> <script name="json"> module.exports = { 'component': true } </script>
2020-07-10