模拟——获取数据

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>产品</title>
</head>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/1.2.3/axios.js"></script>
<!-- <script src="https://unpkg.com/axios/dist/axios.min.js"></script> -->

<style>
    table{
        border:1px solid #000;
        border-collapse: collapse;
        width: 550px;
    }
    th{
        height: 30px;
        text-align: center;
        vertical-align: middle;
        border:1px solid #000;
    }
    td{
        height: 100px;
        text-align: center;
        vertical-align: middle;
        border:1px solid #000;
    }
    img{
        height: 100px;
        width: 100px;
    }
    a{
        color:#00ff00;
    }
    a:hover{
        color:#ff0000;
    }
    tr th:nth-child(4){
        background-color: #ffffd0;
    }
    tr td:nth-child(4){
        background-color: #ffffd0;
    }
    tr th:nth-child(1){
        width: 100px;
    }
    tr th:nth-child(2){
        width: 150px;
    }
    tr th:nth-child(3){
        width: 150px;
    }
    
</style>
<body>
    <div id="info">
        <div><input type="text" id="product" placeholder="请输入产品名称"> <input type="button" id="search" value="搜索"></div>
        <div id="product">
            <table>
                <tr>
                    <th></th>
                    <th>品牌</th>
                    <th>型号</th>
                    <th>价格</th>
                </tr>
                <tr v-for="item in list">
                    <td><img :src="'http://114.67.241.121:8080/img/'+item.image">
                    </td>
                    <td>{{item.brand}}</td>
                    <td><a href="'http://114.67.241.121:8080/img/'+item.image">{{item.model}}</a></td>
                    <td>{{item.price}}</td>
                </tr>
            </table>
            
        </div>
    </div>
</body>
<script src="./js/jquery-3.1.1.min.js"></script>
<script src="vue.js"></script>
<script type="text/javascript">
    new Vue({
        el:'#info',
        data(){
            return {
                list:[],
            }
        },
        created(){
            axios({
                method:'get',
                url:'http://114.67.241.121:8080/product/list'
            }).then(res=>{
                this.list=res.data.data
            })
        }
    })
</script>
</html>

https://c.binjie.fun/#/chat/1693031421192c​​​​​​

vscode常用插件:

Chinese

Live Server

Axios Snippets

ESLint

JavaScript

open in browser

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值