vue前端

<!-- 练习一 -->
<!-- <script>
  export default{
    data(){
      return {
        count:0
      }
    }
}
</script>

<template>
  <button @click="count++">Count is: {{ count }}</button>
</template>

<style scoped>
  buttton {
    font-weight:bold;
  }
</style> -->

<!-- 练习二 -->
<template>
  <div>
    <div>
      <div><input type="text" placeholder="请输入产品名称">
          <input type="button" id="search" value="搜索" @onclick="loaddata()">
    </div>
    <div id="product"></div>
      <table>
        <tr id="tr-0">
          <th id="th0-tr0">  </th>
          <th class="th0-th">品牌</th>
          <th class="th0-th">型号</th>
          <th class="th0-th">价格</th>
      </tr>
      <tr v-for="(data, index) in datas" :key="index" :class="'tr-'+index" >
        <th><img v-bind:src="['http://114.67.241.121:8080/img/'+data.image]"></th>
        <th>{{ data.brand }}</th>
        <th><a id="model" :href="['http://114.67.241.121:8080/img/'+data.model]">{{ data.model }}</a></th>
        <th>{{ data.price }}</th>
      </tr>
      </table>
    </div>
  </div>
  
  
</template>
<script>
export default{
  data(){
    return{
      title:"you",
      datas:[]
      
    }
  },
  methods:{
    loaddata(){
        this.axios({
          methods: "get",
          url: 'http://114.67.241.121:8080/product/list',
          params:{}
        })
        .then( res=> {
          console.log(res)
          this.datas = res.data
        })
    }
  }
  // created() {
  //   this.axios.get("http://114.67.241.121:8080/product/list")
  //       .then( res=> {
  //         console.log(res)
  //         this.datas = res.data
  //       })
  // }
}
</script>
<style>
  table{
    width:550px;
    border-collapse: collapse;
  }
  th{
    border:1px solid black;
  }
  th{
    vertical-align: middle;
    text-align: center;
  }
  #tr-0{
    height: 30px;
  }
  #tr0-th0{
    width:100px;
  }
  .th0-th{
    width:150px;
  }
  #brand{
    color:red
  }
  #model{
    color:#00ff00;
  }
  .tr-3{
    background-color: #ffffd0;
  }
  img {
			height: 100px;
			width: 100px;
	}
  #model:hover{
    color:#ff0000;
  }
</style>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>产品录入</title>
    <link href="css/input.css" rel="stylesheet" type="text/css" />
    <style>
        #search div:first-child{
            float:left;
            width:100px;
            margin-right:10px;
            text-align: right;
            
        }
        #search input{
            width:150px;
        }
        #error{
            color:#ff0000
        }
        #submit input{
            width:268px;
            margin-top: 0px;
        }

    </style>
</head>
<body>
    <div id="search">
        <div>产品名称:</div>
        <div><input type="text" placeholder="请输入产品名称"></div>

    </div>
    <div id="error"></div>
    <div id="submit"><input type="button" value="录入" onclick="checkData()"></div>
   <script>
        function checkData(){
            let data = document.getElementsByTagName("input")[0].value
            if(data==""){
                document.getElementById("error").innerHTML="产品名称必须输入"
            }else if(/\d/.test(data)){
                document.getElementById("error").innerHTML="产品名称不能有数字"
            }else{
                window.location.href="product.html"
            }
        }
   </script>
</body>
</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值