需求:在不同分类里形成wx:for加载的List,使用自定义组件是最优解吗?
报错:
- Uncaught Error: module "list-Item/list-item.js" is not defined
- Error: Component is not found in path "list-item" (using by "pages/example/example")
自定义组件代码段:(example.wxml):
<!--以上为分类相关代码-->
<!--此处报错2-->
<swiper current="{{currentTab}}" duration="10" bindchange="swiperTab">
<swiper-item>
<list-item inpt="{{inpt}}"></list-item>
</swiper-item>
</swiper>
</view>
自定义组件相关代码:
list-item.wxml:
<view class="item">
<view class="content">
<view class="inpt">{{inpt}}</view>
</view>
</view>
list-litm.js:
Component({
item: {
type: String,
value: '',
},
properties: {
data: {
inpt: "",
},
},
methods: {
clickTab: function (e) {
if (this.data.currentTab === e.target.dataset.current) {
return false;
} else {
that.setData({
currentTab: e.target.dataset.current,
wx.navigateTo({ //此处报错1
url: 'url',
//相应完结括号