<view hidden="{{currentTab!==0}}">
<view wx:for="{{logs}}" wx:for-item="item">
{{logs.pcontent}}
</view>
<view wx:for="{{logs}}" wx:for-item="item">
<image src='{{logs.ppic}}'></image>
</view>
</view>
上面的logs.pcontent可以显示 然而image src='{{logs.ppic}}'显示不出图片
<?php
header("Content-Type:application/json;charset=UTF-8");
$uphonenumber = $_POST['phonenumber'];//post获得手机号码表单值
$json = '';
$data = array();
include('init.php');//链接数据库
//$sql = "SELECT * FROM yffice_project where uphonenumber = $uphonenumber";
$sql = "SELECT * FROM yffice_project where uphonenumber = $uphonenumber";
mysql_query("set names utf8");
$result = mysql_query($sql);//执行sql
if($result){
//echo "查询成功";
while ($row = mysql_fetch_array($result))
{
$data["uid"]=$row["uid"];
$data["pcontent"]=$row["pcontent"];
$data["ppic"]=explode(",",$row["ppic"]);
$data["pdate"]=$row["pdate"];
$data["pweek"]=$row["pweek"];
$data["pweather"]=$row["pweather"];
}
$json=json_encode($data);
echo $json;
}else{
echo "查询失败";
}
mysql_close();//关闭数据库
?>
贴一下我的php代码
没用 我在想是不是我返回是对象不是数组的原因
<image src='{{logs.ppic[item]}}'></image>
这是返回的数据 item.pcontent和item.ppic都是取不到的
我ppic里面是个对象数组
怎么会出不来呢,你看看你的代码写对了吗
<view class="container">
<view wx:for='{{logs}}'>
<view>{{item.pcontent}}</view>
<view>
<image src='{{item.ppic}}'></image>
</view>
</view>
</view>
你这样写我连pcontent都显示不出了
把for循环放在 hidden条件的那个view上 还有for循环的默认名称就是item
<view wx:for='{{logs}}'>
<view>{{item.pcontent}}</view>
<view><images src='{{item.ppic}}'></images></view>
</view>