提交 9efd6047 编写于 作者: M Matt Zabriskie

Adding example

上级 f5f461d8
<!doctype html>
<html>
<head>
<title>axios</title>
<style type="text/css">
body {
color: #222;
font-family: "Helvetica Neue", sans-serif;
font-weight: 200;
margin: 0 50px;
}
a {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a, a:hover, a:focus, a:active {
color: #3378b8;
}
.error {
color: #d9534f;
}
strong {
font-weight: 400;
}
h1 {
color: #666;
font-weight: 300;
}
ul {
padding: 0;
list-style-type: none;
}
li {
margin-bottom: 25px;
}
li img {
border-radius: 3px;
float: left;
margin-right: 25px;
height: 50px;
width: 50px;
}
</style>
</head>
<body>
<h1>People</h1>
<ul id="people"></ul>
<script src="../dist/axios.min.js"></script>
<script>
axios.get('people.json')
.success(function (response) {
var people = [];
response.data.forEach(function (person) {
people.push(
'<li>' +
'<img src="https://avatars.githubusercontent.com/u/' + person.avatar + '?s=50"/>' +
'<strong>' + person.name + '</strong>' +
'<div>Github: <a href="https://github.com/' + person.github + '" target="_blank">' + person.github + '</a></div>' +
'<div>Twitter: <a href="https://twitter.com/' + person.twitter + '" target="_blank">' + person.twitter + '</a></div>' +
'</li>'
);
});
document.getElementById('people').innerHTML = people.join('');
})
.error(function(response) {
document.getElementById('people').innerHTML = '<li class="error">' + response.data + '</li>';
});
</script>
</body>
</html>
\ No newline at end of file
[
{
"name": "Matt Zabriskie",
"github": "mzabriskie",
"twitter": "mzabriskie",
"avatar": "199035"
},
{
"name": "Ryan Florence",
"github": "rpflorence",
"twitter": "ryanflorence",
"avatar": "100200"
},
{
"name": "Kent C. Dodds",
"github": "kentcdodds",
"twitter": "kentcdodds",
"avatar": "1500684"
},
{
"name": "Chris Esplin",
"github": "deltaepsilon",
"twitter": "chrisesplin",
"avatar": "878947"
}
]
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册