<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>html引入vue.js</title>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://cdn.jsdelivr.net/npm/axios@0.12.0/dist/axios.min.js"></script>
<script src="https://cdn.bootcss.com/vue/2.1.0/vue.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdn.bootcss.com/vue-resource/1.0.3/vue-resource.js" type="text/javascript" charset="utf-8">
</script>
</head>
<body>
<div id="app">
<ul>
<li v-for="(item,index) in dataList" :key="index">{{item.title}}</li>
</ul>
</div>
</body>
<script>
var demo=new Vue({
el:'#app',
data() {
return {
dataList:[{
title: '1111',
id: 1,
},{
title: '2222',
id: 2,
}],
title: '测试回显'
}
},
created: function(){
this.getImg() //定义方法
},
methods: {
getImg: function(){
console.log(1111)
//-----------
var that = this;
axios.defaults.headers = {
'content-type': 'application/json;charset=utf-8',
Authorization: window.localStorage.getItem("tokenH"),
appid: window.localStorage.getItem("appid")
}
axios.post('http://192.168.6.19:10097/api/question/commitRandomQuestion', arr).then(function(
response) {
console.log("正常返回:", response);
if (response.data.code == 1000) {
}
}).catch(function(error) {
console.log("报错了", error)
})
//--------------
}
}
})
</script>
</html>