• 三阶段遇到的问题


    刚刚做完三阶段项目  在tp5中里面遇到的一些问题

    当时做的是一个nike商城 当时报错就报错在未定义  这个未定义那个未定义  控制器里面写的是单条查询  代码如下

     public function index(Request $request){
                $this->isLogin();
                $res = Banner::get(1);
                //库存
                $stock=$res->stock;
                $num=$res->num;
                $desc=$res->desc;
                $link=$res->link;
                $path=$res->path;
                $name = $res->name;
                $style = $res->style;
                $this->assign('stock', $stock);
                $this->assign('style', $style);
                $this->assign('num', $num);
                $this->assign('desc', $desc);
                $this->assign('link', $link);
                $this->assign('path', $path);
                $this->assign('name', $name);
                return $this->fetch('details');
            }
    

      查全部的代码如下

    public function index(){
            $this->isLogin();
            $res = Banner::all();
            $data = [];
            foreach ($res as $k => $v) {
                $data[$k] = $v->toArray();
            }
            $imgNum = count($res);
            $this->assign('imgNum', $imgNum);
            $this->assign('data', $data);
            return $this->fetch('index');
        }
    

      html代码

    <ul class="item-content layui-clear">
                    <li class="th th-chk">
                        <div class="select-all">
                            <div class="cart-checkbox">
    <!--                            <input class="CheckBoxShop check" id="" type="checkbox" num="all" name="select-all" value="true">-->
                            </div>
                        </div>
                    </li>
                    <li class="th th-item" style="margin-left: 40px">
                        <div class="item-cont">
                            <td><img width="100" style="margin-top: -34px; margin-left: -110px;" class="picture-thumb" src="{$vo.path}"></td>
                            <div class="text" style="margin-left: 40px">
                                <div class="title" style="margin-left: 20px">{$vo.name}</div>
                                <p style="margin-top: -20px"><span style="margin-left: 163px;">{$vo.link}</span> </p>
    
                            </div>
                        </div>
                    </li>
                    <li class="th th-price" style="margin-left: -16px;">
                        <p style="margin-top: 9px"><span style="margin-left: -167px">{$vo.title}</span></p>
                       <p style="margin-top: -16px;"> <span class="th-su" style="margin-left: 126px">{$vo.desc}</span></p>
                    </li>
                    <li class="th th-amount">
    <!--                    <div class="box-btn layui-clear" style="margin-left: 22px;">-->
    <!--                        <div class="less layui-btn">-</div>-->
    <!--                        <input class="Quantity-input" type="" name="" value="{$vo.num}" disabled="disabled">-->
    <!--                        <div class="add layui-btn">+</div>-->
    <!--                    </div>-->
                    <li class="th th-sum">
                        <span class="sum" style="margin-left: 30px;">{$vo.num}</span>
                    </li>
                    </li>
                    <li class="th th-sum">
                        <span class="sum" style="margin-left: -57px;">{$vo.style}</span>
                    </li>
                    <li class="th th-op">
                        <a style="text-decoration:none" class="ml-5" onclick="deleteImg({$vo.id})"
                           href="#" title="删除">
                            <i class="Hui-iconfont" style="margin-left: -65px">删除</i>
                        </a>
                    </li>
                </ul>
    

      查询全部的时候用foreach    查询单条的时候不用foreach

  • 相关阅读:
    解压 Android 系统中的 system.img
    挂载system.img并提取文件
    [android]system.img文件的打包和解包
    linux修改权限
    不懂这个别说是刷机高手!安卓Recovery你知多少
    Android刷机
    eclipse的“sun.misc.BASE64Encoder”问题解决
    spring的multipartResolver和java后端获取的MultipartHttpServletRequest方法对比 (附:遇到的坑)
    《高性能mysql》笔记(第一章,mysql的架构与历史)
    hystrix流程图收藏
  • 原文地址:https://www.cnblogs.com/LQK157/p/11457147.html
Copyright © 2020-2023  润新知