axios 是一个基于Promise 用于浏览器和 nodejs 的 HTTP 客户端,目前的主流 Vue 项目,都选择 axios 来完成 ajax 请求。
完成的效果图:
数据都是从JSON追加进入页面的,此代码中直接使用了淘宝源,Bootstrap还有Vue。
<script type="text/javascript" src="js/vue.js" ></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.css" />
紧接的是简单的代码样式:
<style>
.desc_title{
display: inline-block;
height: 20px;
overflow: hidden;
text-overflow:ellipsis;
white-space:nowrap;
width: 100%;
}
.price{
font-size: 20px;
font-weight: bold;
color: crimson;
}
.discount{
text-decoration: line-through;
}
</style>
最后是布局和方法: