nodsjs POST请求
PHP
遇到问题:
1.跨域问题
报failed to load response data:no data fond for response with give
header("Content-Type: text/html;charset=utf-8");
header('Access-Control-Allow-Origin: *');
2.遇到这种无法读取undefined的属性(读取'getAttribute') , 导致些图表不出来
echarts.min.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'getAttribute')
解决方法: 封装的JS,在页面也要转入值到JS函数里
前端
1.最大DIV加入 id="Market" v-cloak 对应el: '#Market', 才能把值写入
2.<h4>{{topCounts['order_amount_total']}}</h4>
3.循环 与IF
<div class="countItme" v-for="item in topCounts" v-if="item.count_name=='市场活跃度排行'">
<div class="countNum">{{item.count}}</div>
<div class="countText">{{item.count_name}}</div>
</div>
<script src="./js/index.js"></script>
<script src="./js/vue.js"></script>
<script type="text/javascript">
var vm = new Vue({
el: '#Screen',
data:{
topCounts:[],
StatisticsList:[],
orderList:[],
dotList:[],
user7todayList:[],
order7todaylist:[], //1、定义变量
},
created:function(){
var that = this;
that.commImg = commImg();
that.token = localStorage.getItem('caiToken');
that.id = localStorage.getItem('id');
that.ame = localStorage.getItem('name');
},
mounted:function(){
var that = this;
var postData = {"id":that.id,"token":that.token};
//轮询
lunxun = setInterval(function(){
that.getStatistics(postData);
},10000);
that.getStatistics(postData,1);
that.getStatistics_list(postData,1);
that.order_list(postData,1);
that.doc_list(postData,1);
that.user7today_list(postData,1);
that.order7today_list(postData,1); //定义函数
},
methods:{
getStatistics:function(postData,curIndex){
var that = this;
that.getData('statistics',postData,function(res){
if(res.code==0){
that.$forceUpdate()
return false;
}else{
that.topCounts = res;
}
that.$forceUpdate()//强制刷新
});
},
getStatistics_list:function(postData,curIndex){
var that = this;
that.getData('statistics_list',postData,function(res){
if(res.code==0){
that.$forceUpdate()
return false;
}else{
that.StatisticsList = res.list;
}
that.$forceUpdate()
});
},
getData:function(aggregate,postData,onSuccess){
var url1 = commUrl() + aggregate;
var params = postData;
$.post(url1,params,function(res){
if(res.code == -1){
alert(res.msg);
}else if(res.code == 1){
onSuccess(res.data);
}else{
alert(res.msg);
return false;
}
},'json')
},
order_list:function(postData,curIndex){
var that = this;
that.getData('order_list',postData,function(res){
if(res.code==0){
that.$forceUpdate()
return false;
}else{
that.orderList = res.list; //3.值写入变量
}
that.$forceUpdate() //强制刷新
});
},
doc_list:function(postData,curIndex){
var that = this;
that.getData('dot',postData,function(res){
if(res.code==0){
that.$forceUpdate()
return false;
}else{
that.dotList = res.list;
}
that.$forceUpdate() //强制刷新
});
},
order7today_list:function(postData,curIndex){
var that = this;
that.getData('order7today_list',postData,function(res){
if(res.code==0){
that.$forceUpdate()
return false;
}else{
that.user7todayList = res.list;
}
that.$forceUpdate()
var ledger2X=[];
var ledger2Y=[];
$.each(res.list, function(index,item) {
ledger2X.push(item.x2);
ledger2Y.push(item.x1);
});
Echart2(ledger2X,ledger2Y);
});
},
user7today_list:function(postData,curIndex){
var that = this;
that.getData('user7today_list',postData,function(res){
if(res.code==0){
that.$forceUpdate()
return false;
}else{
that.user7todaylist = res.list;
}
that.$forceUpdate()
var ledger3X=[];
var ledger3Y=[];
$.each(res.list, function(index,item) {
ledger3X.push(item.x2);
ledger3Y.push(item.x1);
});
Echart3(ledger3X,ledger3Y);
});
},
}
});
</script>
index.js
function Echart3(xData,yData){
// 中间省略的数据 准备三项
var item = {
name: '',
value: 1200,
// 柱子颜色
itemStyle: {
color: '#254065'
},
// 鼠标经过柱子颜色
emphasis: {
itemStyle: {
color: '#254065'
}
},
// 工具提示隐藏
tooltip: {
extraCssText: 'opacity:0'
}
};
option = {
// 工具提示
tooltip: {
// 触发类型 经过轴触发axis 经过轴触发item
trigger: 'item',
// 轴触发提示才有效
axisPointer: {
// 默认为直线,可选为:'line' 线效果 | 'shadow' 阴影效果
type: 'shadow'
}
},
// 图表边界控制
grid: {
// 距离 上右下左 的距离
left: '0',
right: '3%',
bottom: '3%',
top: '5%',
// 大小是否包含文本【类似于boxsizing】
containLabel: true,
//显示边框
show: true,
//边框颜色
borderColor: 'rgba(0, 240, 255, 0.3)'
},
// 控制x轴
xAxis: [
{
// 使用类目,必须有data属性
type: 'category',
// 使用 data 中的数据设为刻度文字
data: xData, //['上海', '广州', '北京', '深圳', '合肥', '', '......', '', '杭州', '厦门', '济南', '成都', '重庆'],
// 刻度设置
axisTick: {
// true意思:图形在刻度中间
// false意思:图形在刻度之间
alignWithLabel: false,
show: false
},
//文字
axisLabel: {
color: '#4c9bfd'
}
}
],
// 控制y轴
yAxis: [
{
// 使用数据的值设为刻度文字
type: 'value',
axisTick: {
// true意思:图形在刻度中间
// false意思:图形在刻度之间
alignWithLabel: false,
show: false
},
//文字
axisLabel: {
color: '#4c9bfd'
},
splitLine: {
lineStyle: {
color: 'rgba(0, 240, 255, 0.3)'
}
},
}
],
// 控制x轴
series: [
{
// series配置
// 颜色
itemStyle: {
// 提供的工具函数生成渐变颜色
color: new echarts.graphic.LinearGradient(
// (x1,y2) 点到点 (x2,y2) 之间进行渐变
0, 0, 0, 1,
[
{ offset: 0, color: '#00fffb' }, // 0 起始颜色
{ offset: 1, color: '#0061ce' } // 1 结束颜色
]
)
},
// 图表数据名称
name: '用户统计',
// 图表类型
type: 'bar',
// 柱子宽度
barWidth: '60%',
// 数据
data: yData, //[2100, 1900, 1700, 1560, 1400, item, item, item, 900, 750, 600, 480, 240]
}
]
};
var myechart = echarts.init($('.users .bar')[0]);
myechart.setOption(option);
};
nodsjs POST请求的更多相关文章
- Angular2入门系列教程7-HTTP(一)-使用Angular2自带的http进行网络请求
上一篇:Angular2入门系列教程6-路由(二)-使用多层级路由并在在路由中传递复杂参数 感觉这篇不是很好写,因为涉及到网络请求,如果采用真实的网络请求,这个例子大家拿到手估计还要自己写一个web ...
- Android请求网络共通类——Hi_博客 Android App 开发笔记
今天 ,来分享一下 ,一个博客App的开发过程,以前也没开发过这种类型App 的经验,求大神们轻点喷. 首先我们要创建一个Andriod 项目 因为要从网络请求数据所以我们先来一个请求网络的共通类. ...
- 重温Http协议--请求报文和响应报文
http协议是位于应用层的协议,我们在日常浏览网页比如在导航网站请求百度首页的时候,会先通过http协议把请求做一个类似于编码的工作,发送给百度的服务器,然后在百度服务器响应请求时把相应的内容再通过h ...
- Taurus.MVC 2.2 开源发布:WebAPI 功能增强(请求跨域及Json转换)
背景: 1:有用户反馈了关于跨域请求的问题. 2:有用户反馈了参数获取的问题. 3:JsonHelper的增强. 在综合上面的条件下,有了2.2版本的更新,也因此写了此文. 开源地址: https:/ ...
- nodejs之get/post请求的几种方式
最近一段时间在学习前端向服务器发送数据和请求数据,下面总结了一下向服务器发送请求用get和post的几种不同请求方式: 1.用form表单的方法:(1)get方法 前端代码: <form act ...
- ajax异步请求
做前端开发的朋友对于ajax异步更新一定印象深刻,作为刚入坑的小白,今天就和大家一起聊聊关于ajax异步请求的那点事.既然是ajax就少不了jQuery的知识,推荐大家访问www.w3school.c ...
- C# MVC 5 - 生命周期(应用程序生命周期&请求生命周期)
本文是根据网上的文章总结的. 1.介绍 本文讨论ASP.Net MVC框架MVC的请求生命周期. MVC有两个生命周期,一为应用程序生命周期,二为请求生命周期. 2.应用程序生命周期 应用程序生命周期 ...
- nodejs进阶(5)—接收请求参数
1. get请求参数接收 我们简单举一个需要接收参数的例子 如果有个查找功能,查找关键词需要从url里接收,http://localhost:8000/search?keyword=地球.通过前面的进 ...
- 无法向会话状态服务器发出会话状态请求。请确保 ASP.NET State Service (ASP.NET 状态服务)已启动,并且客户端端口与服务器端口相同。如果服务器位于远程计算机上,请检查。。。
异常处理汇总-服 务 器 http://www.cnblogs.com/dunitian/p/4522983.html 无法向会话状态服务器发出会话状态请求.请确保 ASP.NET State Ser ...
- [转]利用URLConnection来发送POST和GET请求
URL的openConnection()方法将返回一个URLConnection对象,该对象表示应用程序和 URL 之间的通信链接.程序可以通过URLConnection实例向该URL发送请求.读取U ...
随机推荐
- 【pytest】@pytest.fixture与@pytest.mark.parametrize结合实现参数化
背景:测试数据既要在fixture方法中使用,同时也在测试用例中使用 使用方法:在使用parametrize的时候添加"indirect=True"参数.pytest可以实现将参数 ...
- 二叉树系列之Treap树
Treap是一棵拥有键值.优先级两种权值的树 struct node{ int size;//以这个结点为根的子树的结点总数量,用于名次树 int rank;//优先级 int key ...
- 【loguru】Python简单的日志管理模块
简介 在部署一些定时运行或者长期运行的任务时,为了留存一些导致程序出现异常或错误的信息,通常会才用日志的方式来进行记录这些信息. 在 Python 中用到日志记录,那就不可避免地会用到内置的 logg ...
- Java自增自减运算符
3.1自增自减运算符 注意事项: ++和--既可以放在变量的后边,也可以放在变量的前边 单独实用的时候,++和--无论是放在变量的前边还是后边,结果是一样的 参与操作的时候,如果放在变量的后边,先拿变 ...
- 20200924--图像相似度(奥赛一本通P92 5多维数组)
给出两幅相同大小的黑白图像(用0-1矩阵)表示,求它们的相似度.说明:若两幅图像在相同位置上的像素点颜色相同,则称它们在该位置具有相同的像素点.两幅图像的相似度定义为相同像素点数占总像素点数的百分比. ...
- maven工程入门
1. 为什么要使用maven? 毕业开始工作,项目组用的maven-spring开发的,不得不了解一下,看过很多介绍,其中maven最大的特点就是 管理jar包和版本管理 (参考:https://ww ...
- HTML5第五章作业
5.1.3 html 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8" ...
- Javaheima12
Java 不可变集合 如果某个数据不能修改,把它防御性地拷贝到不可变集合红是个很好的实践 或者当集合对象被不可信的库调用时,不可变形式是安全的 创建 再List,Set,Map接口中,都存在of方法, ...
- vue引入多个指令文件
单个指令引入,在main.js(入口JS文件)中引入你已经写好的指令文件,可以省略文件后缀: // main.js import focus from 'xxx/directive'多个指令引入 Vu ...
- selenium+鼠标操作+键盘操作+下拉框+弹出框+滚动条+三种等待--代码
鼠标操作 键盘操作 下拉框 弹出框 滚动条 1 from time import sleep 2 from selenium import webdriver 3 4 driver = webdriv ...