项目分为web后台管理和小程序前台使用,在进行web后台管理开发的时候,因为是小项目,采用了art-template,后台系统没有完全前后端分离。
出现问题1:在浏览器端art-template用each数据没有循环出来。
实现功能:导入excel表上传文件,列表循环出来excel表里的内容
因为是第一次用art-template,去官网看了语法之后就动手写了,ajax请求数据之后能拿到数据,语法也没错,就是循环不出来,百度看别人博客之后找到了原因
<script src="template-web.js"></script>
<script type="text/html" id="temp1">
//id是
//把要循环的html代码放里面
{{each arr}}
{{$value.name}}
{{/each}}
</script>
<script type="text/javascript">
var data = {
list:list //这里list是保存ajax请求的数据数组
};
var html = template('temp1', data);
document.getElementById('main').innerHTML = html; //main指的是tbody的id
</script>
出现问题2:微信小程序button按钮点击页面跳转没反应
原因是要跳转的页面是在tabbar里面(别人博客说的),换成wx.switchTab或wx.reLanuch就好了
问题3:其实不算问题,微信小程序没有table,所以只能自己写一个,下面附代码
wxml文件:
<view class="upcontainer">
<view class="formcontainer">
<view class="upimgbox upimg-title">
<view class="table">
<view class="tr bg-w">
<view class="th">选手</view>
<view class="th">姓名</view>
<block wx:for="{{scoreitemlist}}" wx:key="{{scoreitem}}">
<view class="th">{{item.scoreitem}}得分</view>
</block>
<view class="th">总分</view>
<view class="th">排名</view>
</view>
<block wx:for="{{listData}}" wx:key="{{scorelist}}">
<view class="tr">
<view class="td">{{item.code}}</view>
<view class="td">{{item.text}}</view>
<view class="td">{{item.type}}</view>
<view class="td">{{item.id}}</view>
<view class="td">{{item.name}}</view>
<view class="td">{{item.age}}</view>
</view>
</block>
</view>
</view>
</view>
</view>
wxss文件
}
.formcontainer{
background-color: #fff;
margin:0 20rpx;
padding: 20rpx 0;
box-shadow: 2px 2px 2px 2px rgba(0, 0, 0, 0.1);
border-radius: 10rpx;
}
.upimgbox{
margin:0 10rpx;
border:#e6e6e6 solid 1px;
padding:20rpx 0;
}
.table {
border: 0px solid darkgray;
}
.tr {
display: flex;
width: 100%;
justify-content: center;
border-bottom: #e6e6e6 solid 1px;
align-items: center;
}
.td {
width:40%;
justify-content: center;
text-align: center;
font-size: 28rpx;
border-bottom: #e6e6e6 solid 1px;
padding:20rpx 0;
}
.th {
width: 40%;
justify-content: center;
display: flex;
padding:20rpx 0;
align-items: center;
font-size: 26rpx;
}